コード例 #1
0
        public IActionResult LogInForPartner(string uiLocale, bool isSignUp = false)
        {
            var options = AuthenticationPartnerOptions.Construct(Config);

            switch (options.Experience)
            {
            case PartnerExperience.B2BSelfSignup:
                return(LogInFor(Constants.AuthenticationSchemes.PartnerOpenIdConnect, null, uiLocale));

            case PartnerExperience.IGLM:
            default:
                return(LogInFor(Constants.AuthenticationSchemes.PartnerOpenIdConnect, null, uiLocale, isSignUp));
            }
        }
コード例 #2
0
        private void ConfigurePartnerAuthentication(IConfiguration configuration, AuthenticationBuilder authenticationBuilder)
        {
            var authenticationOptions = AuthenticationPartnerOptions.Construct(Configuration);

            authenticationBuilder.AddOpenIdConnect(Constants.AuthenticationSchemes.PartnerOpenIdConnect, options =>
            {
                options.Authority             = authenticationOptions.Authority;
                options.CallbackPath          = new PathString("/partner-signin-callback");
                options.ClientId              = authenticationOptions.ClientId;
                options.Events                = CreatePartnerOpenIdConnectEvents();
                options.SignedOutCallbackPath = new PathString("/partner-signout-callback");
                //options.Scope.Clear();
                //options.Scope.Add("openid");

                options.TokenValidationParameters = new TokenValidationParameters {
                    NameClaimType = Constants.ClaimTypes.Name
                };
            });
        }
コード例 #3
0
        private IActionResult LogInFor(string authenticationScheme, string policy, string uiLocale, bool isSignUp = false)
        {
            if (!identityService.IsUserLoggedIn(User))
            {
                var authenticationOptions = AuthenticationPartnerOptions.Construct(Config);

                var authProperties = new Dictionary <string, string>
                {
                    { Constants.AuthenticationProperties.Policy, policy }, { Constants.AuthenticationProperties.UILocales, uiLocale }
                };

                if (authenticationScheme == Constants.AuthenticationSchemes.CustomerAuth)
                {
                    var industry = _industryManager.GetIndustry();

                    var background = Request.Cookies[Constants.DemoCookies.BgImageKey];

                    if (string.IsNullOrEmpty(background))
                    {
                        background = $"{Request.Scheme}://{Request.Host}/{industry.DefaultCustomerAuthBackground}".ToBase64Encode();
                    }

                    authProperties.Add(Constants.AuthenticationProperties.BgImage, background);
                    authProperties.Add(Constants.AuthenticationProperties.LogoImage, Request.Cookies[Constants.DemoCookies.LogoImageKey]);
                }

                if (authenticationScheme == Constants.AuthenticationSchemes.BusinessCustomerAuth && isSignUp)
                {
                    return(new RedirectResult("https://aka.ms/woodgrovesuppliersignup"));
                }

                return(new ChallengeResult(
                           authenticationScheme,
                           new AuthenticationProperties(new Dictionary <string, string>(authProperties))
                {
                    RedirectUri = Url.Action("LoggedIn", "Account", null, Request.Scheme)
                }));
            }

            return(RedirectToHome());
        }
コード例 #4
0
        public IActionResult LogInForIndividualCustomer(string uiLocale, bool isSignUp = false)
        {
            var authenticationOptions = AuthenticationPartnerOptions.Construct(Config);

            var configuredPolicy = Request.Cookies[Constants.DemoCookies.DefaultSigninPolicyKey].ToBase64Decode();

            if (!_policyManager.PolicyList.ContainsValue(configuredPolicy))
            {
                configuredPolicy = _policyManager.DefaultSignInPolicy;
            }

            var signInPolicy = string.IsNullOrEmpty(configuredPolicy)
                ? _policyManager.SignUpOrSignInWithPersonalAccountLocalEmailAndSocial
                : configuredPolicy;

            var signUpPolicy = signInPolicy == _policyManager.SignInWithPersonalAccountLocalPhoneWithOtp
                ? _policyManager.SignUpWithPersonalAccountLocalPhoneWithOtp
                : signInPolicy;

            return(LogInFor(Constants.AuthenticationSchemes.CustomerAuth, isSignUp ? signUpPolicy : signInPolicy, uiLocale));
        }