public AuthenticateController(
     IOpenidAuthenticateResourceOwnerAction openidAuthenticateResourceOwnerAction,
     IProfileActions profileActions,
     IDataProtectionProvider dataProtectionProvider,
     IEncoder encoder,
     ITranslationManager translationManager,
     IOpenIdEventSource simpleIdentityServerEventSource,
     IUrlHelperFactory urlHelperFactory,
     IActionContextAccessor actionContextAccessor,
     IEventPublisher eventPublisher,
     IAuthenticationService authenticationService,
     IAuthenticationSchemeProvider authenticationSchemeProvider,
     IUserActions userActions,
     IPayloadSerializer payloadSerializer,
     IConfigurationService configurationService,
     IAuthenticateHelper authenticateHelper,
     IResourceOwnerAuthenticateHelper resourceOwnerAuthenticateHelper,
     IChangePasswordAction changePasswordAction,
     ILoginPwdAuthenticateAction loginPwdAuthenticateAction,
     LoginPasswordOptions basicAuthenticateOptions) : base(openidAuthenticateResourceOwnerAction, profileActions, dataProtectionProvider, encoder,
                                                           translationManager, simpleIdentityServerEventSource, urlHelperFactory, actionContextAccessor, eventPublisher,
                                                           authenticationService, authenticationSchemeProvider, userActions, payloadSerializer, configurationService,
                                                           authenticateHelper, basicAuthenticateOptions)
 {
     _resourceOwnerAuthenticateHelper = resourceOwnerAuthenticateHelper;
     _changePasswordAction            = changePasswordAction;
     _loginPwdAuthenticateAction      = loginPwdAuthenticateAction;
 }
Example #2
0
        private LoginPasswordOptions GetOptions()
        {
            var result = new LoginPasswordOptions();

            if (_properties != null)
            {
                bool isEditCredentialsEnabled = false;
                result.ClaimsIncludedInUserCreation = _properties.TryGetArr("ClaimsIncludedInUserCreation");
                if (_properties.TryGetValue("IsEditCredentialEnabled", out isEditCredentialsEnabled))
                {
                    result.IsEditCredentialEnabled = isEditCredentialsEnabled;
                }
            }

            return(result);
        }
Example #3
0
        public static IServiceCollection AddLoginPasswordAuthentication(this IServiceCollection services, IMvcBuilder mvcBuilder, LoginPasswordOptions basicAuthenticateOptions)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (mvcBuilder == null)
            {
                throw new ArgumentNullException(nameof(mvcBuilder));
            }

            if (basicAuthenticateOptions == null)
            {
                throw new ArgumentNullException(nameof(basicAuthenticateOptions));
            }

            var assembly             = typeof(AuthenticateController).Assembly;
            var embeddedFileProvider = new EmbeddedFileProvider(assembly);

            services.Configure <RazorViewEngineOptions>(opts =>
            {
                opts.FileProviders.Add(embeddedFileProvider);
                opts.CompilationCallback = (context) =>
                {
                    var assm            = MetadataReference.CreateFromFile(Assembly.Load("SimpleIdServer.Authenticate.Basic").Location);
                    context.Compilation = context.Compilation.AddReferences(assm);
                };
            });
            services.AddSingleton(basicAuthenticateOptions);
            services.AddTransient <IAuthenticateResourceOwnerService, PasswordAuthenticateResourceOwnerService>();
            services.AddTransient <IChangePasswordAction, ChangePasswordAction>();
            services.AddTransient <ILoginPwdAuthenticateAction, LoginPwdAuthenticateAction>();
            services.AddAuthBasic();
            services.AddSingleton <IAuthModule>(new PwdAuthModule(basicAuthenticateOptions.IsEditCredentialEnabled));
            mvcBuilder.AddApplicationPart(assembly);
            return(services);
        }
        public static IRouteBuilder UseLoginPasswordAuthentication(this IRouteBuilder routeBuilder, LoginPasswordOptions options)
        {
            if (routeBuilder == null)
            {
                throw new ArgumentNullException(nameof(routeBuilder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            routeBuilder.MapRoute("PasswordAuthentication",
                                  Constants.AMR + "/Authenticate/{action}/{id?}",
                                  new { controller = "Authenticate", action = "Index", area = Constants.AMR },
                                  constraints: new { area = Constants.AMR });
            if (options.IsEditCredentialEnabled)
            {
                routeBuilder.MapRoute("PwdEditCredential",
                                      Constants.AMR + "/EditCredential/{action}/{id?}",
                                      new { controller = "EditCredential", action = "Index", area = Constants.AMR },
                                      constraints: new { area = Constants.AMR });
            }

            routeBuilder.MapRoute("PwdConfiguration",
                                  Constants.AMR + "/Configuration",
                                  new { controller = "Configuration", action = "Index", area = Constants.AMR },
                                  constraints: new { area = Constants.AMR });
            routeBuilder.MapRoute("PwdEditCredentialApi",
                                  Constants.AMR + "/Credentials/{action}/{id?}",
                                  new { controller = "Credentials", action = "Index", area = Constants.AMR },
                                  constraints: new { area = Constants.AMR });
            return(routeBuilder);
        }