Example #1
0
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();

            context.Validated();
            return(Task.FromResult <object>(null));
        }
Example #2
0
    public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
    {
        context.Validated();

        return(Task.FromResult(0));
        //return base.ValidateAuthorizeRequest(context);
    }
Example #3
0
 /// <summary>
 /// 验证 authorization_code 的请求
 /// </summary>
 public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     if (context.AuthorizeRequest.ClientId == "xishuai" && (context.AuthorizeRequest.IsAuthorizationCodeGrantType || context.AuthorizeRequest.IsImplicitGrantType))
     {
         context.Validated();
     }
     else
     {
         context.Rejected();
     }
 }
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var clientService = mobSocialEngine.ActiveEngine.Resolve <IClientService>();
            var client        = clientService.FirstOrDefault(x => x.Guid == context.AuthorizeRequest.ClientId);

            context.OwinContext.Set <string>("as:client_id", client.Guid);
            context.OwinContext.Set <string>("as:clientAccessTokenLifeTime", client.RefreshTokenLifeTime.ToString());

            context.Validated();
            return(Task.FromResult <object>(null));
        }
 public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     // validation d'une authorize request
     if (context.AuthorizeRequest.ClientId == "win8client" && context.AuthorizeRequest.IsAuthorizationCodeGrantType)
     {
         context.Validated();
     }
     else
     {
         context.Rejected();
     }
 }
 public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     // validation d'une authorize request
     if (context.AuthorizeRequest.ClientId == "win8client" && context.AuthorizeRequest.IsAuthorizationCodeGrantType)
     {
         context.Validated();
     }
     else
     {
         context.Rejected();
     }
 }
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            if (context.AuthorizeRequest.IsImplicitGrantType || context.AuthorizeRequest.IsAuthorizationCodeGrantType)
            {
                context.Validated();
            }
            else
            {
                context.Rejected();
            }

            return(Task.FromResult(0));
        }
Example #8
0
        /// <summary>
        /// 验证 authorization_code 的请求
        /// </summary>
        public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var identityRepository = IdentityRepositoryFactory.CreateInstance();

            if (await identityRepository.ExistsClientId(context.AuthorizeRequest.ClientId) &&
                (context.AuthorizeRequest.IsAuthorizationCodeGrantType || context.AuthorizeRequest.IsImplicitGrantType))
            {
                context.Validated();
            }
            else
            {
                context.Rejected();
            }
        }
Example #9
0
        /// <summary>
        /// 验证 authorization_code 的请求
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var client = ClientRepository.Clients.Where(x => x.id == context.AuthorizeRequest.ClientId).FirstOrDefault();

            //授权方式为 授权码或者简化模式
            if (client != null && (context.AuthorizeRequest.IsAuthorizationCodeGrantType || context.AuthorizeRequest.IsImplicitGrantType))
            {
                context.Validated();
            }
            else
            {
                context.Rejected();
            }
        }
Example #10
0
 /// <summary>
 /// 第二步
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     //获取code的时候会调用
     return(Task.Factory.StartNew(() =>
     {
         if (string.IsNullOrEmpty(context.ClientContext.ClientId))
         {
             context.SetCustomError("client_id不能为空");
         }
         else if (context.ClientContext.ClientId.StartsWith("AAA") == false)
         {
             context.SetCustomError("客户端未授权");
         }
         else
         {
             context.Validated();
         }
     }));
 }
Example #11
0
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            if (!ObjectId.TryParse(context.AuthorizeRequest.ClientId, out var mongoObjectId))
            {
                context.SetError("invalid_request");
                return(Task.CompletedTask);
            }
            var client =
                _clientManager.Clients.FirstOrDefault(
                    c => c.Id.Equals(context.AuthorizeRequest.ClientId) &&
                    c.RedirectUrl.Equals(context.AuthorizeRequest.RedirectUri));

            if (client == null)
            {
                context.SetError("invalid_client");
            }
            else
            {
                context.Validated();
            }
            return(Task.CompletedTask);
        }
        /// <summary>
        /// 验证 authorization_code 的请求
        /// </summary>
        public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            logger.Debug("ValidateAuthorizeRequest");
            var client = Clients.ApiClients.Where(a => a.AppId == context.AuthorizeRequest.ClientId);

            if (client != null &&
                (context.AuthorizeRequest.IsAuthorizationCodeGrantType ||
                 context.AuthorizeRequest.IsImplicitGrantType))
            {
                /*
                 * Marks this context as validated by the application. IsValidated becomes true
                 * and HasError becomes false as a result of calling.
                 */
                var validateResult = await Task.FromResult(context.Validated());
            }
            else
            {
                /* Marks this context as not validated by the application. IsValidated and HasError
                 * become false as a result of calling.
                 */
                context.Rejected();
            }
        }
Example #13
0
        private async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var clientManager = context.OwinContext.Get <ApplicationClientManager>();
            var clientScopes  = await clientManager.GetUserRolesAsync(context.AuthorizeRequest.ClientId);

            var oauthScopes = new List <dynamic> {
                new { scope = "scope_base", order = 0 }, new { scope = "scope_userinfo", order = 0 }
            };
            var scopes     = context.AuthorizeRequest.Scope;
            var isInScopes = scopes.Any(s =>
            {
                return(oauthScopes.Any(w => w.order > 0 && w.scope.Equals(s, StringComparison.OrdinalIgnoreCase)));
            });

            if (!isInScopes)
            {
                context.ClientContext.Rejected();
                context.Rejected();
                context.SetError("invalid_scope", "Invalid Scope");
                return;
            }
            context.Validated();
            await Task.FromResult(0);
        }
 /// <summary>
 /// 验证 authorization_code 的请求
 /// </summary>
 public override async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     if (context.AuthorizeRequest.ClientId == "shoy" &&
         (context.AuthorizeRequest.IsAuthorizationCodeGrantType || context.AuthorizeRequest.IsImplicitGrantType))
     {
         context.Validated();
     }
     else
     {
         context.Rejected();
     }
 }
 /// <summary>
 /// 2
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     context.Validated();
     return(base.ValidateAuthorizeRequest(context));
 }
        /// <summary>
        /// Called for each request to the Authorize endpoint to determine if the request is valid and should continue.
        /// The default behavior when using the OAuthAuthorizationServerProvider is to assume well-formed requests, with
        /// validated client redirect URI, should continue processing. An application may add any additional constraints.
        /// </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 ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            this.options.Logger.Debug("Authorize request is valid");

            context.Validated();
        }
 /// <summary>
 /// <![CDATA[验证请求]]>
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     context.Validated();
     return(Task.FromResult <object>(0));
 }
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var clientService = mobSocialEngine.ActiveEngine.Resolve<IClientService>();
            var client = clientService.FirstOrDefault(x => x.Guid == context.AuthorizeRequest.ClientId);

            context.OwinContext.Set<string>("as:client_id", client.Guid);
            context.OwinContext.Set<string>("as:clientAccessTokenLifeTime", client.RefreshTokenLifeTime.ToString());

            context.Validated();
            return Task.FromResult<object>(null);
        }
Example #19
0
        /// <summary>
        /// Called for each request to the Authorize endpoint to determine if the request is valid and should continue.
        /// The default behavior when using the OAuthAuthorizationServerProvider is to assume well-formed requests, with
        /// validated client redirect URI, should continue processing. An application may add any additional constraints.
        /// </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 ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            this.options.Logger.Debug("Authorize request is valid");

            context.Validated();
        }