/// <summary> /// 验证 access_token 的请求 /// </summary> /// <param name="context"></param> /// <returns></returns> public override async Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { if (context.TokenRequest.IsClientCredentialsGrantType) { context.Validated(); } else { context.Rejected(); } }
/// <summary> /// 验证 access_token 的请求 /// </summary> public override async Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { if (context.TokenRequest.IsAuthorizationCodeGrantType || context.TokenRequest.IsRefreshTokenGrantType || context.TokenRequest.IsResourceOwnerPasswordCredentialsGrantType) { context.Validated(); } else { context.Rejected(); } }
public override async Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { // valide la requète de token // dans note cas on accepte les requètes de type "authorize code" et "refresh_token" if (context.TokenRequest.IsAuthorizationCodeGrantType || context.TokenRequest.IsRefreshTokenGrantType) { context.Validated(); } else { context.Rejected(); } }
/// <summary> /// 验证 access_token 的请求 /// </summary> public override Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { if (context.TokenRequest.IsAuthorizationCodeGrantType || context.TokenRequest.IsClientCredentialsGrantType || context.TokenRequest.IsRefreshTokenGrantType || context.TokenRequest.IsResourceOwnerPasswordCredentialsGrantType) { context.Validated(); } else { context.Rejected(); } return(Task.FromResult <object>(null)); }
/// <summary> /// 验证Token请求,限制授权模式 /// </summary> /// <param name="context"></param> /// <returns></returns> public override Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { //设置暂时只支持密码模式 if (context.TokenRequest.IsResourceOwnerPasswordCredentialsGrantType) { context.Validated(); } else { context.Rejected(); return(Task.FromResult <object>(null)); } return(base.ValidateTokenRequest(context)); }
/// <summary> /// 验证 access_token 的请求 /// </summary> /// <param name="context"></param> /// <returns></returns> public override async Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { if (context.TokenRequest.IsClientCredentialsGrantType) { context.Validated(); } //if (context.TokenRequest.IsAuthorizationCodeGrantType || context.TokenRequest.IsRefreshTokenGrantType) //{ // context.Validated(); //} else { context.Rejected(); } }
/// <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> /// <remarks> /// This validates the grant_type accepted and also processes CORS /// </remarks> public override Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { //TODO: Determine which grant types will will actually support - these will probably be the only ones if (!context.TokenRequest.IsAuthorizationCodeGrantType && !context.TokenRequest.IsResourceOwnerPasswordCredentialsGrantType && !context.TokenRequest.IsRefreshTokenGrantType) { context.Rejected(); context.SetError("invalid_grant_type", "Only grant_type=authorization_code, grant_type=password or grant_type=refresh_token are accepted by this server."); return(Task.FromResult(0)); } ProcessCors(context); return(base.ValidateTokenRequest(context)); }
/// <summary> /// 验证 access_token 的请求 /// </summary> public override async Task ValidateTokenRequest(OAuthValidateTokenRequestContext context) { logger.Debug("ValidateTokenRequest"); if ( context.TokenRequest.IsAuthorizationCodeGrantType || context.TokenRequest.IsClientCredentialsGrantType || context.TokenRequest.IsRefreshTokenGrantType || context.TokenRequest.IsResourceOwnerPasswordCredentialsGrantType ) { /* * 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 { context.Rejected(); } }
public static void SetCustomError(this OAuthValidateTokenRequestContext context, string msg) { context.Rejected(); ResponseWrite(context.Response, msg); }