Exemplo n.º 1
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 2
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (var item in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(item.Key, item.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 3
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            var exceptionHandler           = Helper.GetOwinScopeService <IOwinExceptionHandler>(context.OwinContext);
            var authorizationServerHandler = Helper.GetOwinScopeService <IFifthweekAuthorizationServerHandler>(context.OwinContext);

            return(ProviderErrorHandler.CallAndHandleError(
                       () => authorizationServerHandler.TokenEndpointAsync(context),
                       context.Request,
                       exceptionHandler));
        }
Exemplo n.º 4
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            //edit format default context's properties here: access_token, token_type, expires_in, .issued, .expires

            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }//end for add data include in AuthenticationProperties
            return(Task.FromResult <object>(null));
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            //context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 6
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }
            //context.AdditionalResponseParameters.Add("UserID", context.Identity.GetUserId());     //dodanie ID do tokena

            return(Task.FromResult <object>(null));
        }
        //5th
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            Debug.WriteLine("************ApplicationOAuthprovider (TokenEndpoint) **********");
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 8
0
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     //addedd
     context.AdditionalResponseParameters.Add("path", userPathFromRole.Trim(new Char[] { '"', '[', ']' }));
     //--
     return(Task.FromResult <object>(null));
 }
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     if (Additional != null)
     {
         foreach (var row in Additional)
         {
             context.AdditionalResponseParameters.Add(row.Key, row.Value);
         }
     }
     return(base.TokenEndpoint(context));
 }
Exemplo n.º 10
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            var accessExpiration = DateTimeOffset.Now.AddDays(30);

            context.Properties.ExpiresUtc = accessExpiration;
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
 /// <summary>
 /// Tokens the endpoint.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (var property in context.Properties.Dictionary)
     {
         if (property.Key.StartsWith("."))
         {
             continue;
         }
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     return(base.TokenEndpoint(context));
 }
        // Add additional parameter to return with response
        public override Task TokenEndpoint(OAuthTokenEndpointContext oAuthTokenEndpointContext)
        {
            // Add authentication properties via iterate which is added as a part of GrantResourceOwnerCredentials()
            foreach (KeyValuePair <string, string> property in oAuthTokenEndpointContext.Properties.Dictionary)
            {
                oAuthTokenEndpointContext.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            oAuthTokenEndpointContext.AdditionalResponseParameters.Add("TestParam1", "Value1");
            oAuthTokenEndpointContext.AdditionalResponseParameters.Add("TestParam2", "Value2");

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 13
0
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     //ClaimsIdentity claimsIdentity = context.Identity.Claims.FirstOrDefault(u=>u.c;
     if (context.Properties.Dictionary["role"] == "admin")
     {
         context.Properties.ExpiresUtc = DateTime.UtcNow.AddDays(1);
     }
     return(Task.FromResult <object>(null));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     if (context.TokenIssued)
     {
         var tokenClaimsDeviceInfo = context.Identity.Claims.Where(c => c.Type.StartsWith("deviceId"));
         if (tokenClaimsDeviceInfo != null && tokenClaimsDeviceInfo.FirstOrDefault() != null)
         {
             string _deviceInfo = tokenClaimsDeviceInfo.FirstOrDefault().Value;
             context.AdditionalResponseParameters.Add("DeviceInformation", _deviceInfo);
         }
     }
     return(base.TokenEndpoint(context));
 }
        public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            ApplicationUserManager userManager = context.Request.Context.GetUserManager <ApplicationUserManager>();
            IdentityUser           user        = await userManager.FindByIdAsync(context.Identity.GetUserId());

            if (user != null)
            {
                IList <string> roles = await userManager.GetRolesAsync(user.Id);

                /*context.AdditionalResponseParameters.Add("isUser", roles.Contains(AppConsts.UserRoleName));
                 * context.AdditionalResponseParameters.Add("isAdmin", roles.Contains(AppConsts.AdminRoleName));*/
            }
        }
Exemplo n.º 16
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            var tokenString = JsonConvert.SerializeObject(_idToken, Formatting.None,
                                                          new JsonSerializerSettings
            {
                ContractResolver      = new CamelCasePropertyNamesContractResolver(),
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
            }
                                                          );

            context.AdditionalResponseParameters.Add("id_token", tokenString);
            return(Task.FromResult(true));
        }
Exemplo n.º 17
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            if (!String.IsNullOrEmpty(this.token))
            {
                context.Properties.Dictionary.Add("refresh_token", this.token);
            }
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }
            // ja dodala:
            // context.AdditionalResponseParameters.Add("userID", context.Identity.GetUserId());
         //context.AdditionalResponseParameters.Add("Role", context.Identity.);
            //ili ovo : HttpContext.Current.User.Identity.GetUserId();


            return Task.FromResult<object>(null);
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }


            string role = context.Identity.Claims.Where(c => c.Type.Contains("role")).Select(c => c.Value).SingleOrDefault();

            context.AdditionalResponseParameters.Add("user_role", role);

            return(Task.FromResult <object>(null));
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            var x = CreateProperties(_userName, _displayName, _userEmail);

            x.Dictionary.ForEach(c => context.Properties.Dictionary.Add(c));


            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 21
0
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     //add user Id and status as additional response parameter
     context.AdditionalResponseParameters.Add("id", userFinded.id);
     context.AdditionalResponseParameters.Add("username", userFinded.username);
     context.AdditionalResponseParameters.Add("userType", userFinded.userType);
     context.AdditionalResponseParameters.Add("firstName", userFinded.firstName);
     context.AdditionalResponseParameters.Add("lastName", userFinded.lastName);
     context.AdditionalResponseParameters.Add("cellPhone", userFinded.cellPhone);
     context.AdditionalResponseParameters.Add("address", userFinded.address);
     context.AdditionalResponseParameters.Add("emailAddress", userFinded.emailAddress);
     context.AdditionalResponseParameters.Add("userLoggedTypeId", userLoggedTypeId);
     context.AdditionalResponseParameters.Add("pictureUrl", userFinded.pictureUrl);
     return(base.TokenEndpoint(context));
 }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            var roles = context.Identity.Claims.Where(c => c.Type == ClaimTypes.Role).Select(c => c.Value).ToList();

            //У нас нет множественных ролей, так что...
            var role = roles.First();

            context.AdditionalResponseParameters.Add("role", role);
            return(Task.FromResult <object>(null));
        }
Exemplo n.º 23
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            //RETURN THE USER NAME
            var             userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();
            ApplicationUser user        = userManager.FindById(context.Identity.GetUserId());

            context.AdditionalResponseParameters.Add("Name", user.Name);

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 24
0
        public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            context.AdditionalResponseParameters.Add("empresaId", _usuario.EmpresaId);
            context.AdditionalResponseParameters.Add("ImagemUsuario", _usuario.ImagemUsuario);
            context.AdditionalResponseParameters.Add("EmpresaImagem", _usuario.Empresa.EmpresaImagem);
            context.AdditionalResponseParameters.Add("NomeEmpresa", _usuario.Empresa.NomeEmpresa);

            foreach (var role in _roles)
            {
                context.AdditionalResponseParameters.Add("roles", role.Key);
                context.AdditionalResponseParameters.Add("IdRole", role.Value);
            }

            await Task.FromResult(context);
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            context.AdditionalResponseParameters.Add("Admin", Usuario.UserAdmin);
            context.AdditionalResponseParameters.Add("Organizador", Usuario.Organizador);
            context.AdditionalResponseParameters.Add("CaixaEvento", Usuario.CaixaEvento);
            context.AdditionalResponseParameters.Add("UsuarioPrincipal", Usuario.UserPrincipal);
            context.AdditionalResponseParameters.Add("id_usuario_principal", Usuario.Id_Usuario_Principal);
            context.AdditionalResponseParameters.Add("id_usuario_organizador", Usuario.id_usuario_organizador);

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 26
0
        public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            // Remember me
            var tokenData = await context.Request.ReadFormAsync();

            bool.TryParse(tokenData.Get("rememberMe"), out var rememberMe);
            if (rememberMe)
            {
                context.Properties.ExpiresUtc = DateTime.UtcNow.AddYears(1);
            }

            foreach (var property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Called at the final stage of a successful Token endpoint request. 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 Token endpoint's json response body.
        /// </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 TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            var claims = context.Identity.Claims;

            if (claims.Count(e => e.Value == "ManageAreaPaziente") > 0)
            {
                context.Properties.ExpiresUtc = DateTime.UtcNow.AddYears(1);
            }

            return(base.TokenEndpoint(context));
        }
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            Dictionary <string, string> additionalUserInfo = new Dictionary <string, string>();

            foreach (Claim claim in context.Identity.Claims)
            {
                context.AdditionalResponseParameters.Add(claim.Type.Split('/').Last(), claim.Value);
            }

            foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 29
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (var item in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(item.Key, item.Value);
            }
            var claims = context.Identity.Claims
                         .GroupBy(x => x.Type)
                         .Select(y => new { Claim = y.Key, Value = y.Select(a => a.Value).ToArray() });

            foreach (var item in claims)
            {
                context.AdditionalResponseParameters.Add(item.Claim, JsonConvert.SerializeObject(item.Value));
            }
            return(base.TokenEndpoint(context));
        }
Exemplo n.º 30
0
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            if (context.Request.Method == "OPTIONS")
            {
                context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
                context.OwinContext.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "authorization" });
                context.RequestCompleted();

                foreach (KeyValuePair <string, string> property in context.Properties.Dictionary)
                {
                    context.AdditionalResponseParameters.Add(property.Key, property.Value);
                }
            }

            return(Task.FromResult <object>(null));
        }
 /// <summary>
 /// Called at the final stage of a successful Token endpoint request. 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 Token endpoint's json response body.
 /// </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 TokenEndpoint(OAuthTokenEndpointContext context)
 {
     return OnTokenEndpoint.Invoke(context);
 }