简体   繁体   English

在 wso2 如何编写自定义 OAuth2 令牌验证器

[英]In wso2 how to write custom OAuth2 token validator

In wso2 identity server how we can write custom Oauth2 token validator.在 wso2 身份服务器中,我们如何编写自定义 Oauth2 令牌验证器。 As in wso2 identity server documentation there is no sample code available.与 wso2 身份服务器文档一样,没有可用的示例代码。 And also how we can query oidc scope inside token validator for getting custom claims.以及我们如何在令牌验证器中查询 oidc scope 以获取自定义声明。

According to the documentation what you are looking for is OAuth2 Token Validator根据文档,您正在寻找的是OAuth2 Token Validator

public class SO62997622 implements org.wso2.carbon.identity.oauth2.validators.OAuth2TokenValidator {

    @Override
    public boolean validateAccessDelegation(OAuth2TokenValidationMessageContext oatvmc) throws IdentityOAuth2Exception {
        // Validate access
        return false;
    }

    @Override
    public boolean validateScope(OAuth2TokenValidationMessageContext oatvmc) throws IdentityOAuth2Exception {
        // Validate scopes
        return false;
    }

    @Override
    public boolean validateAccessToken(OAuth2TokenValidationMessageContext oatvmc) throws IdentityOAuth2Exception {
        // Validate the actual token
        return false;
    }

}

The documentation also has directions on how to enable your custom OAuth token validator and a Default implementation Class you can build upon.该文档还包含有关如何启用您的自定义 OAuth 令牌验证器和您可以构建的默认实现 Class 的说明。 This is assuming Identity Server version 5.9 but should be pretty similar in previous versions.这假设 Identity Server 版本为 5.9,但在以前的版本中应该非常相似。

For the second part of your question maybe Claims Retriever is what you are looking for?对于您问题的第二部分,您正在寻找的可能是Claims Retriever

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM