Beispiel #1
0
        internal static void CheckLicense(this IEndpointRouteBuilder endpoints)
        {
            if (_licenseChecked == false)
            {
                var loggerFactory = endpoints.ServiceProvider.GetRequiredService <ILoggerFactory>();
                var options       = endpoints.ServiceProvider.GetRequiredService <BffOptions>();

                LicenseValidator.Initalize(loggerFactory, options);
                LicenseValidator.ValidateLicense();
            }

            _licenseChecked = true;
        }
Beispiel #2
0
        private static bool CanStart()
        {
            string licenseFilePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + ApplicationSettings.LicenseFileName;

            try
            {
                return(LicenseValidator.ValidateLicense(licenseFilePath));
            }
            catch (Exception ex)
            {
                MessageBoxHelper.ShowError(ex.Message);
                return(false);
            }
        }
    internal static void Validate(this IApplicationBuilder app)
    {
        var loggerFactory = app.ApplicationServices.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

        if (loggerFactory == null)
        {
            throw new ArgumentNullException(nameof(loggerFactory));
        }

        var logger = loggerFactory.CreateLogger("Duende.IdentityServer.Startup");

        logger.LogInformation("Starting Duende IdentityServer version {version} ({netversion})", typeof(Duende.IdentityServer.Hosting.IdentityServerMiddleware).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion, RuntimeInformation.FrameworkDescription);

        var scopeFactory = app.ApplicationServices.GetService <IServiceScopeFactory>();

        using (var scope = scopeFactory.CreateScope())
        {
            var serviceProvider = scope.ServiceProvider;

            var options = serviceProvider.GetRequiredService <IdentityServerOptions>();
            var env     = serviceProvider.GetRequiredService <IHostEnvironment>();
            LicenseValidator.Initalize(loggerFactory, options, env.IsDevelopment());
            LicenseValidator.ValidateLicense();

            TestService(serviceProvider, typeof(IPersistedGrantStore), logger, "No storage mechanism for grants specified. Use the 'AddInMemoryPersistedGrants' extension method to register a development version.");
            TestService(serviceProvider, typeof(IClientStore), logger, "No storage mechanism for clients specified. Use the 'AddInMemoryClients' extension method to register a development version.");
            TestService(serviceProvider, typeof(IResourceStore), logger, "No storage mechanism for resources specified. Use the 'AddInMemoryIdentityResources' or 'AddInMemoryApiResources' extension method to register a development version.");

            var persistedGrants = serviceProvider.GetService(typeof(IPersistedGrantStore));
            if (persistedGrants.GetType().FullName == typeof(InMemoryPersistedGrantStore).FullName)
            {
                logger.LogInformation("You are using the in-memory version of the persisted grant store. This will store consent decisions, authorization codes, refresh and reference tokens in memory only. If you are using any of those features in production, you want to switch to a different store implementation.");
            }

            ValidateOptions(options, logger);

            ValidateAsync(serviceProvider, logger).GetAwaiter().GetResult();
        }
    }