Пример #1
0
        public static OpenIddictCoreBuilder UseOrchardManagers(this OpenIddictCoreBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.ReplaceApplicationManager(typeof(OpenIdApplicationManager <>))
            .ReplaceAuthorizationManager(typeof(OpenIdAuthorizationManager <>))
            .ReplaceScopeManager(typeof(OpenIdScopeManager <>))
            .ReplaceTokenManager(typeof(OpenIdTokenManager <>));

            // Register proxy delegates so that the Orchard managers can be directly
            // resolved from the DI using the non-generic, Orchard-specific interfaces.
            builder.Services.TryAddScoped(provider => (IOpenIdApplicationManager)
                                          provider.GetRequiredService <IOpenIddictApplicationManager>());
            builder.Services.TryAddScoped(provider => (IOpenIdAuthorizationManager)
                                          provider.GetRequiredService <IOpenIddictAuthorizationManager>());
            builder.Services.TryAddScoped(provider => (IOpenIdScopeManager)
                                          provider.GetRequiredService <IOpenIddictScopeManager>());
            builder.Services.TryAddScoped(provider => (IOpenIdTokenManager)
                                          provider.GetRequiredService <IOpenIddictTokenManager>());

            return(builder);
        }
        public static OpenIddictCoreBuilder UseThreaxIdServerEf(this OpenIddictCoreBuilder builder, Action <Options> configure)
        {
            var options = new Options();

            configure.Invoke(options);

            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            // Since Entity Framework Core may be used with databases performing case-insensitive
            // or culture-sensitive comparisons, ensure the additional filtering logic is enforced
            // in case case-sensitive stores were registered before this extension was called.
            builder.Configure(options => options.DisableAdditionalFiltering = false);

            builder.SetDefaultApplicationEntity <Client>()
            .SetDefaultAuthorizationEntity <Authorization>()
            .SetDefaultScopeEntity <Scope>()
            .SetDefaultTokenEntity <Token>();

            builder.ReplaceApplicationStoreResolver <ApplicationStoreResolver>()
            .ReplaceAuthorizationStoreResolver <AuthorizationStoreResolver>()
            .ReplaceScopeStoreResolver <ScopeStoreResolver>()
            .ReplaceTokenStoreResolver <TokenStoreResolver>();

            builder.ReplaceApplicationManager(typeof(ThreaxOpenIddictApplicationManager <>));

            builder.Services.TryAddScoped <ApplicationStore>();
            builder.Services.TryAddScoped <AuthorizationStore>();
            builder.Services.TryAddScoped <ScopeStore>();
            builder.Services.TryAddScoped <TokenStore>();

            builder.Services.AddDbContext <ConfigurationDbContext>(o =>
            {
                options.SetupConfigurationDbContext.Invoke(o);
            });

            builder.Services.AddDbContext <OperationDbContext>(o =>
            {
                options.SetupOperationDbContext.Invoke(o);
            });

            return(builder);
        }
Пример #3
0
        public static OpenIddictCoreBuilder UseEpiManagers(this OpenIddictCoreBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.ReplaceApplicationManager(typeof(EpiOpenIdApplicationManager <>));
            builder.ReplaceScopeManager(typeof(EpiOpenIdScopeManager <>));
            builder.ReplaceAuthorizationManager(typeof(EpiOpenIdAuthorizationManager <>));
            builder.ReplaceTokenManager(typeof(EpiOpenIdTokenManager <>));

            builder.Services.TryAddScoped(provider => (IEpiOpenIdApplicationManager)
                                          provider.GetRequiredService <IOpenIddictApplicationManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdScopeManager)
                                          provider.GetRequiredService <IOpenIddictScopeManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdAuthorizationManager)
                                          provider.GetRequiredService <IOpenIddictAuthorizationManager>());
            builder.Services.TryAddScoped(provider => (IEpiOpenIdTokenManager)
                                          provider.GetRequiredService <IOpenIddictTokenManager>());

            return(builder);
        }