Exemplo n.º 1
1
 private async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     var output = context.Request.Get<TextWriter>("host.TraceOutput");
     output.WriteLine("Authorize Request {0} {1} {2}",
         context.ClientContext.ClientId,
         context.AuthorizeRequest.ResponseType,
         context.AuthorizeRequest.RedirectUri);
 }
Exemplo n.º 2
0
    public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
    {
        context.Validated();

        return(Task.FromResult(0));
        //return base.ValidateAuthorizeRequest(context);
    }
Exemplo n.º 3
0
        public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();

            context.Validated();
            return(Task.FromResult <object>(null));
        }
Exemplo n.º 4
0
        private async Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
        {
            var output = context.Request.Get <TextWriter>("host.TraceOutput");

            output.WriteLine("Authorize Request {0} {1} {2}",
                             context.ClientContext.ClientId,
                             context.AuthorizeRequest.ResponseType,
                             context.AuthorizeRequest.RedirectUri);
        }
        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));
        }
Exemplo n.º 6
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 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));
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 12
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();
         }
     }));
 }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 15
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);
        }
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     return(base.ValidateAuthorizeRequest(context));
 }
 /// <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>
        /// 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();
        }
Exemplo n.º 19
0
		//public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context) {
		//	if (context.ClientId == _publicClientId) {
		//		Uri expectedRootUri = new Uri(context.Request.Uri, "/");

		//		if (expectedRootUri.AbsoluteUri == context.RedirectUri) {
		//			context.Validated();
		//		} else if (context.ClientId == "web") {
		//			var expectedUri = new Uri(context.Request.Uri, "/");
		//			context.Validated(expectedUri.AbsoluteUri);
		//		}
		//	}

		//	return Task.FromResult<object>(null);
		//}

		public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context) {
			return base.ValidateAuthorizeRequest(context);
		}
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     Debug.Write("ValidateAuthorizeRequest");
     return base.ValidateAuthorizeRequest(context);
 }
Exemplo n.º 21
0
 public static void SetCustomError(this OAuthValidateAuthorizeRequestContext context, string msg)
 {
     context.Rejected();
     ResponseWrite(context.Response, msg);
 }
Exemplo n.º 22
0
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     Debug.Write("ValidateAuthorizeRequest");
     return(base.ValidateAuthorizeRequest(context));
 }
        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 Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     throw new NotImplementedException();
 }
 public Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 26
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();
        }
 /// <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 virtual Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     return OnValidateAuthorizeRequest.Invoke(context);
 }
 /// <summary>
 /// <![CDATA[验证请求]]>
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task ValidateAuthorizeRequest(OAuthValidateAuthorizeRequestContext context)
 {
     context.Validated();
     return(Task.FromResult <object>(0));
 }