private void AddButtons(UserInteractionOptions options)
        {
            const int buttonWidth = 100;
            var       buttonBar   = root.FindControl <IPanel>("ButtonBar");

            // create all the buttons
            foreach (var option in GetFlags(options))
            {
                var button = new Button {
                    Content = Enum.GetName(typeof(UserInteractionOptions), option), Width = buttonWidth
                };
                buttonBar.Children.Add(button);
                button.Click += (sender, e) =>
                {
                    interaction.UserInteractionResult = (UserInteractionOptions)option;
                    Close();
                };
            }

            int buttonCount = buttonBar.Children.Count;
            // this has to be changed if the ButtonBar isnt a StackPanel anymore!
            var bar = buttonBar as StackPanel;

            bar.Width = buttonWidth * buttonCount;
        }
Esempio n. 2
0
 public UserController(IUserService userService, AppSettings appSettings, UserInteractionOptions interactionOptions, IValidationComponent validationComponent, IExternalClient externalClient, IIdentityServerInteractionService interaction, IExternalUserCacheStrategy externalUserService, Domain.Options.Endpoints endpoints, IMessageStore <ErrorMessage> errorMessageStore)
 {
     _userService         = userService;
     _appSettings         = appSettings;
     _interactionOptions  = interactionOptions;
     _validationComponent = validationComponent;
     _externalClient      = externalClient;
     _interaction         = interaction;
     _externalUserService = externalUserService;
     _endpoints           = endpoints;
     _errorMessageStore   = errorMessageStore;
 }
Esempio n. 3
0
        private void ConfigureIdentityServer(IServiceCollection services, UserInteractionOptions userInteractionOptions, AppSettings appSettings)
        {
            var identityServerBuilder = services.AddIdentityServer(o =>
            {
                o.Authentication = new AuthenticationOptions
                {
                    CookieLifetime          = TimeSpan.FromSeconds(7200),
                    CookieSlidingExpiration = false
                };
                o.InputLengthRestrictions = new InputLengthRestrictions
                {
                    Password    = 256,
                    TokenHandle = 200
                };
                o.IssuerUri          = "http://localhost:80";
                o.AccessTokenJwtType = "JWT";
                o.UserInteraction    = userInteractionOptions;
            });

            var cookieDomain = Configuration["CookieDomain"];

            if (!cookieDomain.IsEmpty())
            {
                services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme,
                           opt => { opt.Cookie.Domain = Configuration["CookieDomain"]; });
                services.AddAuthorization(opt =>
                {
                    opt.AddPolicy("TwoFactorEnabled", x => x.RequireClaim("amr", "mfa"));
                });
            }

            identityServerBuilder.AddSigningCredential(new X509Certificate2(Hex.Decode(appSettings.X509RawCertData), appSettings.X509CertPwd));
            identityServerBuilder.AddClientStore <ClientStore>();
            identityServerBuilder.AddResourceStore <ResourceStore>();
            identityServerBuilder.AddPersistedGrantStore <PersistedGrantStore>();
            identityServerBuilder.AddResourceOwnerValidator <ResourceOwnerPasswordValidator>();
            identityServerBuilder.AddRedirectUriValidator <RedirectUriValidator>();
            identityServerBuilder.AddCustomAuthorizeRequestValidator <CustomAuthorizeRequestValidator>();
            identityServerBuilder.AddExtensionGrantValidator <SmsGrantValidator>();
            identityServerBuilder.AddExtensionGrantValidator <ExternalGrantValidator>();

            services.AddTransient <IHandleGenerationService, CustomHandleGenerationService>();
            services.AddTransient <IAuthorizationCodeStore, AuthorizationCodeStore>();
        }
Esempio n. 4
0
 public ConsentPageResult(UserInteractionOptions options, string returnUrl)
     : base(options.ConsentUrl, options.ConsentReturnUrlParameter, returnUrl)
 {
 }
Esempio n. 5
0
 public LoginPageResult(UserInteractionOptions options, string returnUrl)
     : base(options.LoginUrl, options.LoginReturnUrlParameter, returnUrl)
 {
 }
 public CompatibilityPassportMiddleware(RequestDelegate next, UserInteractionOptions userInteractionOptions)
 {
     _next = next;
     _userInteractionOptions = userInteractionOptions;
 }
Esempio n. 7
0
 public LogoutPageResult(UserInteractionOptions options, string id = null)
     : base(options.LogoutUrl, options.LogoutIdParameter, id)
 {
 }
Esempio n. 8
0
 public ErrorPageResult(UserInteractionOptions options, string id)
     : base(options.ErrorUrl, options.ErrorIdParameter, id)
 {
 }