public async Task <OidcProvider> GetById(string oidcProviderId)
        {
            OidcProvider foundProvider =
                _providers.FirstOrDefault(x => x.OidcProviderId == oidcProviderId);

            return(foundProvider);
        }
        public async Task Update(OidcProvider updatedProvider)
        {
            OidcProvider found =
                _providers
                .FirstOrDefault(x => x.OidcProviderId == updatedProvider.OidcProviderId);

            found.AuthorityUrl         = updatedProvider.AuthorityUrl;
            found.ClientId             = updatedProvider.ClientId;
            found.ClientSecret         = updatedProvider.ClientSecret;
            found.ExpectedResponseType = updatedProvider.ExpectedResponseType;
            found.Name = updatedProvider.Name;
            found.RequireHttpsMetadata = updatedProvider.RequireHttpsMetadata;
            found.ScopesToRequest      = updatedProvider.ScopesToRequest;
        }
Exemplo n.º 3
0
        public void PostConfigure(string name, OpenIdConnectOptions options)
        {
            OidcProvider provider =
                Task.Run <OidcProvider>(async() => {
                OidcProvider foundProvider = await _oidcProviderStore.GetById(name);
                return(foundProvider);
            })
                .Result;

            if (provider != null)
            {
                options.SignInScheme         = "ExternalCookie";
                options.Authority            = provider.AuthorityUrl;
                options.ClientId             = provider.ClientId;
                options.ClientSecret         = provider.ClientSecret;
                options.ResponseType         = provider.ExpectedResponseType;
                options.RequireHttpsMetadata = provider.RequireHttpsMetadata;

                // Callback paths must be unique per provider
                options.CallbackPath          = $"/callbacks/oidc/{provider.OidcProviderId}/signin";
                options.SignedOutCallbackPath = $"/callbacks/oidc/{provider.OidcProviderId}/signout";

                options.Events = new OpenIdConnectEvents
                {
                    OnRemoteFailure = async context =>
                    {
                        context.Response.Redirect("/");
                        context.HandleResponse();
                    }
                };
            }
            else
            {
                throw new InvalidOperationException("Trying to use an unexisting OIDC provider");
            }
        }
 public async Task Create(OidcProvider newProvider)
 {
     _providers.Add(newProvider);
 }