public async Task <IActionResult> Edit([FromRoute] string providerId)
        {
            OidcProvider provider = await _oidcProviderStore.GetById(providerId);

            OidcProviderUpdateViewModel vm = new OidcProviderUpdateViewModel();

            vm.AuthorityUrl         = provider.AuthorityUrl;
            vm.ClientId             = provider.ClientId;
            vm.ClientSecret         = provider.ClientSecret;
            vm.ExpectedResponseType = provider.ExpectedResponseType;
            vm.Name                 = provider.Name;
            vm.ProviderId           = provider.OidcProviderId;
            vm.RequireHttpsMetadata = provider.RequireHttpsMetadata;
            vm.ScopesToRequest      = string.Join(" ", provider.ScopesToRequest);

            return(View(vm));
        }
Exemplo n.º 2
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");
            }
        }