【发布时间】:2018-12-12 10:33:24
【问题描述】:
目前正在使用 WSO2 API Manager 版本 2.2.0。 OAuth 2.0 的实现非常好。
当我们通过 WSO2 API Store 定义一个新的应用程序时,我们可以生成 Consumer Key 和 Secret 并选择 Grant Type 来生成 Access Token。之后,我们应该使用一些订阅层订阅 API。
然后在 API 调用期间授权访问令牌(也称为 API 密钥)。访问令牌链接到属性,然后将其放入AuthenticationContext,如下面的org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.java 摘录:
APIKeyValidationInfoDTO info;
info = keyValidator.getKeyValidationInfo(apiContext, apiKey, apiVersion, authenticationScheme, clientDomain,
matchingResource, httpMethod, defaultVersionInvoked);
if (info.isAuthorized()) {
AuthenticationContext authContext = new AuthenticationContext();
authContext.setAuthenticated(true);
authContext.setTier(info.getTier());
authContext.setApiKey(apiKey);
authContext.setKeyType(info.getType());
authContext.setUsername(info.getEndUserName());
authContext.setCallerToken(info.getEndUserToken());
authContext.setApplicationId(info.getApplicationId());
authContext.setApplicationName(info.getApplicationName());
authContext.setApplicationTier(info.getApplicationTier());
authContext.setSubscriber(info.getSubscriber());
authContext.setConsumerKey(info.getConsumerKey());
APISecurityUtils.setAuthenticationContext(synCtx, authContext, securityContextHeader);
这是完美的工作,但现在,我想拥有自己的自定义身份验证处理程序,它不是基于访问令牌,而是基于 X.509 证书,其中 CN 将是我的实体标识 (Writing Custom Handlers)。
此外,我还想利用应用程序设置和订阅层来管理使用 X.509 证书调用 API 的不同实体的此类属性。使用上面提到的调用它不起作用,因为我没有任何apiKey。
我正在尝试找到一种方法,如何从 X.509 证书而不是访问令牌中获取带有标识的应用程序 API 数据,以设置订阅层和其他 AuthenticationContext 属性。
有什么建议可以做吗?
【问题讨论】:
标签: authentication wso2 access-token wso2-am x509