Пример #1
0
        GetIdentityBaseContextAsync()
        {
            var context = new IdentityBaseContext();

            string returnUrl = this._httpContextAccessor
                               .HttpContext.Request.Query["ReturnUrl"];

            if (this._interactionService.IsValidReturnUrl(returnUrl))
            {
                await this.SetAuthorizationRequest(context, returnUrl);

                await this.SetClientInfoAsync(context,
                                              context.AuthorizationRequest.ClientId);

                return(context);
            }

            string logoutId = this._httpContextAccessor
                              .HttpContext.Request.Query["LogoutId"];

            if (!String.IsNullOrWhiteSpace(logoutId))
            {
                await this.SetLogoutRequest(context, logoutId);

                await this.SetClientInfoAsync(context,
                                              context.LogoutRequest.ClientId);

                return(context);
            }

            return(await base.GetIdentityBaseContextAsync());
        }
        public static IdentityBaseContext GetIdentityBaseContext(
            this HttpContext httpContext)
        {
            IdentityBaseContext identityBaseContext =
                httpContext
                .RequestServices
                .GetService <IdentityBaseContext>();

            return(identityBaseContext);
        }
Пример #3
0
        /// <summary>
        /// Creates <see cref="IdentityBaseContext"/>from logoutId.
        /// </summary>
        /// <param name="logoutId"></param>
        /// <returns></returns>
        private async Task SetLogoutRequest(
            IdentityBaseContext context,
            string logoutId)
        {
            LogoutRequest request = await this._interactionService
                                    .GetLogoutContextAsync(logoutId);

            if (request == null)
            {
                return;
            }

            context.LogoutId      = logoutId;
            context.LogoutRequest = request;
        }
Пример #4
0
        // TODO: return theme object instead of string
        public string GetTheme()
        {
            HttpContext context = this._httpContextAccessor.HttpContext;

            IdentityBaseContext identityBaseContext =
                context.GetIdentityBaseContext();

            if (!identityBaseContext.IsValid)
            {
                return("Default");
            }

            ClientProperties clientProperties = identityBaseContext.Client
                                                .Properties.ToObject <ClientProperties>();

            string theme = clientProperties.Theme ?? "Default";

            return(theme);
        }
Пример #5
0
        /// <summary>
        /// Creates <see cref="IdentityBaseContext"/>from returnUrl.
        /// </summary>
        /// <param name="returnUrl"></param>
        /// <returns></returns>
        private async Task SetAuthorizationRequest(
            IdentityBaseContext context,
            string returnUrl)
        {
            if (String.IsNullOrEmpty(returnUrl))
            {
                return;
            }

            AuthorizationRequest request =
                await this._interactionService
                .GetAuthorizationContextAsync(returnUrl);

            if (request == null)
            {
                return;
            }

            context.ReturnUrl            = returnUrl;
            context.AuthorizationRequest = request;
        }