Example #1
0
        public static IIdentityServerBuilder AddWsFederation(this IIdentityServerBuilder builder)
        {
            builder.Services.AddTransient <WsFederationMetadataGenerator>();
            builder.Services.AddTransient <IWsFederationRequestValidator, WsFederationRequestValidator>();
            builder.Services.AddTransient <IWsFederationResponseGenerator, WsFederationSigninResponseGenerator>();

            builder.AddEndpoint <WsFederationMetadataEndpoint>("Metadata", "/wsfederation/metadata");
            builder.AddEndpoint <WsFederationSigninEndpoint>("Signin", "/wsfederation/signin");
            return(builder);
        }
        public static IIdentityServerBuilder AddWsFederation(this IIdentityServerBuilder builder, Action <WsFederationOptions> optionsCallback = null)
        {
            builder.Services.AddTransient <WsFederationMetadataGenerator>();

            var options = new WsFederationOptions();

            optionsCallback?.Invoke(options);

            builder.Services.AddSingleton(options);
            builder.Services.AddTransient <IWsFederationRequestValidator, WsFederationRequestValidator>();
            builder.Services.AddTransient <IWsFederationResponseGenerator, WsFederationSigninResponseGenerator>();

            builder.AddEndpoint <WsFederationMetadataEndpoint>("Metadata", "/wsfederation/metadata");
            builder.AddEndpoint <WsFederationEndpoint>("Signin", "/wsfederation");
            return(builder);
        }
        public static IIdentityServerBuilder AddMockedUserInfoEndpoint(this IIdentityServerBuilder builder)
        {
            AddDependencies(builder.Services);

            builder.AddEndpoint <UserInfoEndpoint>("UserinfoMock", "/connect/userinfo_mock");

            return(builder);
        }
        private static void ReplaceEndSessionEndpoint(IIdentityServerBuilder builder)
        {
            // We don't have a better way to replace the end session endpoint as far as we know other than looking the descriptor up
            // on the container and replacing the instance. This is due to the fact that we chain on AddIdentityServer which configures the
            // list of endpoints by default.
            var endSessionEndpointDescriptor = builder.Services
                                               .Single(s => s.ImplementationInstance is Endpoint e &&
                                                       string.Equals(e.Name, "Endsession", StringComparison.OrdinalIgnoreCase) &&
                                                       string.Equals("/connect/endsession", e.Path, StringComparison.OrdinalIgnoreCase));

            builder.Services.Remove(endSessionEndpointDescriptor);
            builder.AddEndpoint <AutoRedirectEndSessionEndpoint>("EndSession", "/connect/endsession");
        }
Example #5
0
        /// <summary>
        /// Adds the default endpoints.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public static IIdentityServerBuilder AddDefaultEndpoints(this IIdentityServerBuilder builder)
        {
            builder.Services.AddTransient <IEndpointRouter, EndpointRouter>();

            builder.AddEndpoint <AuthorizeEndpoint>(EndpointNames.Authorize, ProtocolRoutePaths.Authorize.EnsureLeadingSlash());
            builder.AddEndpoint <CheckSessionEndpoint>(EndpointNames.CheckSession, ProtocolRoutePaths.CheckSession.EnsureLeadingSlash());
            builder.AddEndpoint <DiscoveryEndpoint>(EndpointNames.Discovery, ProtocolRoutePaths.DiscoveryConfiguration.EnsureLeadingSlash());
            builder.AddEndpoint <EndSessionEndpoint>(EndpointNames.EndSession, ProtocolRoutePaths.EndSession.EnsureLeadingSlash());
            builder.AddEndpoint <IntrospectionEndpoint>(EndpointNames.Introspection, ProtocolRoutePaths.Introspection.EnsureLeadingSlash());
            builder.AddEndpoint <TokenRevocationEndpoint>(EndpointNames.Revocation, ProtocolRoutePaths.Revocation.EnsureLeadingSlash());
            builder.AddEndpoint <TokenEndpoint>(EndpointNames.Token, ProtocolRoutePaths.Token.EnsureLeadingSlash());
            builder.AddEndpoint <UserInfoEndpoint>(EndpointNames.UserInfo, ProtocolRoutePaths.UserInfo.EnsureLeadingSlash());

            return(builder);
        }
        public static IIdentityServerBuilder AddMyIdentityServer(
            this IIdentityServerBuilder builder)
        {
            //builder.Services.AddSingleton<ITokenResponseGenerator, MyTokenResponseGenerator>();
            builder.Services.TryGetDescriptors(typeof(Endpoint), out var descriptors);

            var services = builder.Services;

            var descriptor = descriptors.FirstOrDefault(p => ((Endpoint)p.ImplementationInstance).Name == "Token");

            if (descriptor != null)
            {
                services.Remove(descriptor);
            }

            var descriptorIntrospection = descriptors.FirstOrDefault(p => ((Endpoint)p.ImplementationInstance).Name == "Introspection");

            if (descriptorIntrospection != null)
            {
                services.Remove(descriptorIntrospection);
            }

            //services.TryGetDescriptors(typeof(IEndpointRouter), out var descriptorsx);
            //foreach (var item in descriptorsx)
            //{
            //    var index = services.IndexOf(item);

            //    //services.Insert(index, item.WithImplementationType(implementationType));

            //    services.Remove(item);
            //}

            //builder.Services.AddTransient<IEndpointRouter, MyEndpointRouter>();


            builder.AddEndpoint <MyEndpointHandler>("Token", ProtocolRoutePaths.Token.EnsureLeadingSlash());
            //builder.AddEndpoint<MyIntrospectionEndpoint>("Introspection", ProtocolRoutePaths.Introspection.EnsureLeadingSlash());

            builder.AddLoginHandler <PasswordLoginHandler>(LoginType.ByPassword);
            builder.AddLoginHandler <PhoneLoginHandler>(LoginType.ByPhone);
            builder.AddLoginHandler <TouristLoginHandler>(LoginType.ByTourist);


            //builder.Services.AddSingleton<IEndpointHandler, MyEndpointHandler>();
            return(builder);
        }
Example #7
0
        /// <summary>
        /// Adds the default endpoints.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public static IIdentityServerBuilder AddDefaultEndpoints(this IIdentityServerBuilder builder)
        {
            builder.Services.AddSingleton <IEndpointRouter>(resolver =>
            {
                return(new EndpointRouter(Constants.EndpointPathToNameMap,
                                          resolver.GetRequiredService <IdentityServerOptions>(),
                                          resolver.GetServices <EndpointMapping>(),
                                          resolver.GetRequiredService <ILogger <EndpointRouter> >()));
            });

            builder.AddEndpoint <AuthorizeEndpoint>(EndpointName.Authorize);
            builder.AddEndpoint <CheckSessionEndpoint>(EndpointName.CheckSession);
            builder.AddEndpoint <DiscoveryEndpoint>(EndpointName.Discovery);
            builder.AddEndpoint <EndSessionEndpoint>(EndpointName.EndSession);
            builder.AddEndpoint <IntrospectionEndpoint>(EndpointName.Introspection);
            builder.AddEndpoint <RevocationEndpoint>(EndpointName.Revocation);
            builder.AddEndpoint <TokenEndpoint>(EndpointName.Token);
            builder.AddEndpoint <UserInfoEndpoint>(EndpointName.UserInfo);

            return(builder);
        }
Example #8
0
        /// <summary>
        /// Adds the default endpoints.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public static IIdentityServerBuilder AddDefaultEndpoints(this IIdentityServerBuilder builder)
        {
            builder.Services.AddTransient <IEndpointRouter, EndpointRouter>();

            builder.AddEndpoint <AuthorizeCallbackEndpoint>(EndpointNames.Authorize, ProtocolRoutePaths.AuthorizeCallback.EnsureLeadingSlash());
            builder.AddEndpoint <AuthorizeEndpoint>(EndpointNames.Authorize, ProtocolRoutePaths.Authorize.EnsureLeadingSlash());
            builder.AddEndpoint <CheckSessionEndpoint>(EndpointNames.CheckSession, ProtocolRoutePaths.CheckSession.EnsureLeadingSlash());
            builder.AddEndpoint <DeviceAuthorizationEndpoint>(EndpointNames.DeviceAuthorization, ProtocolRoutePaths.DeviceAuthorization.EnsureLeadingSlash());
            builder.AddEndpoint <DiscoveryKeyEndpoint>(EndpointNames.Discovery, ProtocolRoutePaths.DiscoveryWebKeys.EnsureLeadingSlash());
            builder.AddEndpoint <DiscoveryEndpoint>(EndpointNames.Discovery, ProtocolRoutePaths.DiscoveryConfiguration.EnsureLeadingSlash());
            builder.AddEndpoint <EndSessionCallbackEndpoint>(EndpointNames.EndSession, ProtocolRoutePaths.EndSessionCallback.EnsureLeadingSlash());
            builder.AddEndpoint <EndSessionEndpoint>(EndpointNames.EndSession, ProtocolRoutePaths.EndSession.EnsureLeadingSlash());
            builder.AddEndpoint <IntrospectionEndpoint>(EndpointNames.Introspection, ProtocolRoutePaths.Introspection.EnsureLeadingSlash());
            builder.AddEndpoint <TokenRevocationEndpoint>(EndpointNames.Revocation, ProtocolRoutePaths.Revocation.EnsureLeadingSlash());
            builder.AddEndpoint <TokenEndpoint>(EndpointNames.Token, ProtocolRoutePaths.Token.EnsureLeadingSlash());
            builder.AddEndpoint <UserInfoEndpoint>(EndpointNames.UserInfo, ProtocolRoutePaths.UserInfo.EnsureLeadingSlash());
            builder.AddEndpoint <RegisterEndpoint>(EndpointNames.Register, ProtocolRoutePaths.Register.EnsureLeadingSlash());
            builder.AddEndpoint <VerifiedEmailEndpoint>(EndpointNames.VerifiedEmail, ProtocolRoutePaths.VerifiedEmail.EnsureLeadingSlash());
            builder.AddEndpoint <PushOTPEmailEndpoint>(EndpointNames.PushOTPEmail, ProtocolRoutePaths.PushOTPEmail.EnsureLeadingSlash());
            builder.AddEndpoint <PushSMSEndpoint>(EndpointNames.PushSMS, ProtocolRoutePaths.PushSMS.EnsureLeadingSlash());
            builder.AddEndpoint <GenerateOTPEndpoint>(EndpointNames.RequestOTP, ProtocolRoutePaths.RequestOTP.EnsureLeadingSlash());
            builder.AddEndpoint <UpdateUserEndpoint>(EndpointNames.UpdateUser, ProtocolRoutePaths.UpdateUser.EnsureLeadingSlash());
            builder.AddEndpoint <CreateRolesEndpoint>(EndpointNames.CreateRoles, ProtocolRoutePaths.CreateRoles.EnsureLeadingSlash());
            builder.AddEndpoint <UpdateRolesEndpoint>(EndpointNames.UpdateRoles, ProtocolRoutePaths.UpdateRoles.EnsureLeadingSlash());
            builder.AddEndpoint <GetRolesEndpoint>(EndpointNames.GetListRoles, ProtocolRoutePaths.GetListRoles.EnsureLeadingSlash());
            builder.AddEndpoint <GetUserDetailByIdEndpoint>(EndpointNames.GetUserDetail, ProtocolRoutePaths.GetUserDetail.EnsureLeadingSlash());
            builder.AddEndpoint <GenerateOTPTempEndpoint>(EndpointNames.RequestOTPTemp, ProtocolRoutePaths.RequestOTPTemp.EnsureLeadingSlash());
            builder.AddEndpoint <DeleteUserEndpoint>(EndpointNames.DeleteUsers, ProtocolRoutePaths.DeleteUsers.EnsureLeadingSlash());

            return(builder);
        }
Example #9
0
 private static void RegisterEndpoints(this IIdentityServerBuilder builder)
 {
     builder.AddEndpoint <InitRegistrationEndpoint>("TrustedDeviceInitRegistration", "/my/devices/register/init");
     builder.AddEndpoint <CompleteRegistrationEndpoint>("TrustedDeviceCompleteRegistration", "/my/devices/register/complete");
     builder.AddEndpoint <DeviceAuthorizationEndpoint>("TrustedDeviceAuthorization", "/my/devices/connect/authorize");
 }