Ejemplo n.º 1
0
        public static OpenIddictCoreBuilder UseEpiInmemoryStore(this OpenIddictCoreBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Configure(options => options.DisableAdditionalFiltering = false);

            builder.SetDefaultApplicationEntity <EpiOpenIdApplication>();
            builder.SetDefaultScopeEntity <EpiOpenIdScope>();
            builder.SetDefaultAuthorizationEntity <EpiOpenIdAuthorization>();
            builder.SetDefaultTokenEntity <EpiOpenIdToken>();

            builder.ReplaceApplicationStoreResolver <EpiOpenIdApplicationStoreResolver>();
            builder.ReplaceScopeStoreResolver <EpiOpenIdScopeStoreResolver>();
            builder.ReplaceAuthorizationStoreResolver <EpiOpenIdAuthorizationStoreResolver>();
            builder.ReplaceTokenStoreResolver <EpiOpenIdTokenStoreResolver>();

            builder.Services.TryAddSingleton <EpiOpenIdApplicationStoreResolver.TypeResolutionCache>();
            builder.Services.TryAddSingleton <EpiOpenIdScopeStoreResolver.TypeResolutionCache>();
            builder.Services.TryAddSingleton <EpiOpenIdAuthorizationStoreResolver.TypeResolutionCache>();
            builder.Services.TryAddSingleton <EpiOpenIdTokenStoreResolver.TypeResolutionCache>();

            builder.Services.TryAddScoped(typeof(EpiOpenIdApplicationStore <>));
            builder.Services.TryAddScoped(typeof(EpiOpenIdScopeStore <>));
            builder.Services.TryAddScoped(typeof(EpiOpenIdAuthorizationStore <>));
            builder.Services.TryAddScoped(typeof(EpiOpenIdTokenStore <>));

            return(builder);
        }