/// <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)); }
/// <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(); } }
/// <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(); } }
/// <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(); } }
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 static void SetCustomError(this OAuthValidateAuthorizeRequestContext context, string msg) { context.Rejected(); ResponseWrite(context.Response, msg); }
/// <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(); } }