Exemplo n.º 1
0
        public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
        {
            var redirectUri = context.AuthorizeEndpointRequest.RedirectUri;

            if (context.AuthorizeEndpointRequest.IsAuthorizationCodeGrantType)
            {
                redirectUri = $"{redirectUri}?code={context.AuthorizationCode}&redirect_uri={context.AuthorizeEndpointRequest.RedirectUri}";
                if (!string.IsNullOrEmpty(context.AuthorizeEndpointRequest.State))
                {
                    redirectUri = $"{redirectUri}&state={context.AuthorizeEndpointRequest.State}";
                }
            }
            if (context.AuthorizeEndpointRequest.IsImplicitGrantType)
            {
                redirectUri = $"{redirectUri}?access_token={context.AccessToken}";
                if (!string.IsNullOrEmpty(context.AuthorizeEndpointRequest.State))
                {
                    redirectUri += $"&state={context.AuthorizeEndpointRequest.State}";
                }
                redirectUri += $"&token_type=bearer&expires_in={context.Properties.ExpiresUtc}";
            }
            context.Response.Redirect(redirectUri);
            context.RequestCompleted();
            return(Task.CompletedTask);
            //return base.AuthorizationEndpointResponse(context);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
        {
            var refreshToken = context.OwinContext.Authentication.AuthenticationResponseGrant.Properties.Dictionary["refresh_token"];

            if (!string.IsNullOrEmpty(refreshToken))
            {
                context.AdditionalResponseParameters.Add("refresh_token", refreshToken);
            }
            return(base.AuthorizationEndpointResponse(context));
        }
Exemplo n.º 3
0
        private void SignIn(List <Claim> claims, OAuthAuthorizationEndpointResponseContext HttpContext)//Mind!!! This is System.Security.Claims not WIF claims
        {
            var claimsIdentity = new DemoIdentity(claims,
                                                  DefaultAuthenticationTypes.ApplicationCookie);

            LoggingHelper.AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            LoggingHelper.AuthenticationManager.SignIn(new AuthenticationProperties()
            {
                IsPersistent = false
            }, claimsIdentity);
        }
Exemplo n.º 4
0
        public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
        {
            var props = context.OwinContext.Authentication.AuthenticationResponseGrant.Properties.Dictionary;

            foreach (var k in props.Keys)
            {
                if (k[0] != '.' && !string.Equals(k, "client_id", StringComparison.OrdinalIgnoreCase))
                {
                    context.AdditionalResponseParameters.Add(k, props[k]);
                }
            }
            return(base.AuthorizationEndpointResponse(context));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called before the AuthorizationEndpoint redirects its response to the caller. The response could be the
        /// token, when using implicit flow or the AuthorizationEndpoint when using authorization code flow.
        /// An application may implement this call in order to do any final modification of the claims being used
        /// to issue access or refresh tokens. This call may also be used in order to add additional
        /// response parameters to the authorization endpoint's response.
        /// </summary>
        /// <param name="context">The context of the event carries information in and results out.</param>
        /// <returns>Task to enable asynchronous execution</returns>
        public override async Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
        {
            if (!context.IsRequestCompleted && context.AuthorizeEndpointRequest.IsImplicitGrantType)
            {
                var refreshTokenCreateContext = new AuthenticationTokenCreateContext(
                    context.OwinContext,
                    context.Options.RefreshTokenFormat,
                    new AuthenticationTicket(context.Identity, context.Properties));
                await context.Options.RefreshTokenProvider.CreateAsync(refreshTokenCreateContext);

                string refreshToken = refreshTokenCreateContext.Token;
                context.AdditionalResponseParameters.Add("refresh_token", refreshToken);
            }
            await base.AuthorizationEndpointResponse(context);
        }
        //added

        public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
        {
            //  Add the claims to the return url
            foreach (var claim in context.Identity.Claims)
            {
                if (claim.Type == ClaimsIdentity.DefaultNameClaimType)
                {
                    context.AdditionalResponseParameters.Add("username", claim.Value);
                }
                else if (claim.Type == ClaimTypes.Email)
                {
                    context.AdditionalResponseParameters.Add("email", claim.Value);
                }
            }
            return(base.AuthorizationEndpointResponse(context));
        }
 /// <summary>
 /// Called before the AuthorizationEndpoint redirects its response to the caller. The response could be the
 /// token, when using implicit flow or the AuthorizationEndpoint when using authorization code flow.  
 /// An application may implement this call in order to do any final modification of the claims being used 
 /// to issue access or refresh tokens. This call may also be used in order to add additional 
 /// response parameters to the authorization endpoint's response.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>Task to enable asynchronous execution</returns>
 public virtual Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     return OnAuthorizationEndpointResponse.Invoke(context);
 }
 public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     return(base.AuthorizationEndpointResponse(context));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Called before the AuthorizationEndpoint redirects its response to the caller. The response could be the
 ///             token, when using implicit flow or the AuthorizationEndpoint when using authorization code flow.  
 ///             An application may implement this call in order to do any final modification of the claims being used 
 ///             to issue access or refresh tokens. This call may also be used in order to add additional 
 ///             response parameters to the authorization endpoint's response.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>
 /// Task to enable asynchronous execution
 /// </returns>
 public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     //  Add the claims to the return url
     foreach (var claim in context.Identity.Claims)
     {
         if (claim.Type == ClaimsIdentity.DefaultNameClaimType)
         {
             context.AdditionalResponseParameters.Add("username", claim.Value);
         }
         else if (claim.Type == ClaimTypes.Email)
         {
             context.AdditionalResponseParameters.Add("email", claim.Value);
         }
     }
     return base.AuthorizationEndpointResponse(context);
 }
Exemplo n.º 10
0
 public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     var props = context.OwinContext.Authentication.AuthenticationResponseGrant.Properties.Dictionary;
     foreach (var k in props.Keys)
     {
         if (k[0] != '.' && !string.Equals(k,"client_id",StringComparison.OrdinalIgnoreCase))
         {
             context.AdditionalResponseParameters.Add(k, props[k]);
         }
     }
     return base.AuthorizationEndpointResponse(context);
 }
 /// <summary>
 /// Called before the AuthorizationEndpoint redirects its response to the caller. The response could be the
 /// token, when using implicit flow or the AuthorizationEndpoint when using authorization code flow.
 /// An application may implement this call in order to do any final modification of the claims being used
 /// to issue access or refresh tokens. This call may also be used in order to add additional
 /// response parameters to the authorization endpoint's response.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>Task to enable asynchronous execution</returns>
 public override async Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     await base.AuthorizationEndpointResponse(context);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Called before the AuthorizationEndpoint redirects its response to the caller. The response could be the
 /// token, when using implicit flow or the AuthorizationEndpoint when using authorization code flow.
 /// An application may implement this call in order to do any final modification of the claims being used
 /// to issue access or refresh tokens. This call may also be used in order to add additional
 /// response parameters to the authorization endpoint's response.
 /// </summary>
 /// <param name="context">The context of the event carries information in and results out.</param>
 /// <returns>Task to enable asynchronous execution</returns>
 public override async Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     await base.AuthorizationEndpointResponse(context);
 }
Exemplo n.º 13
0
 public override Task AuthorizationEndpointResponse(OAuthAuthorizationEndpointResponseContext context)
 {
     
     return base.AuthorizationEndpointResponse(context);
 }