有没有办法在 WSO2 JWT Grant 流程中不生成刷新令牌?

Is there a way not to generate a refresh token in the WSO2 JWT Grant flow?

我正在使用 JWT Grant 将外部身份提供商生成的 JWT 令牌交换为 WSO2 访问令牌。

执行此操作的客户端是 public 浏览器,所以我不想使用 refresh_token。有没有办法配置 WSO2 API 管理器,使其不生成 refresh_token?

注释掉 "repository/conf/identity/identity.xml" 文件中的刷新令牌授予处理程序。这将全局禁用刷新令牌授予处理程序。

<SupportedGrantType>
    <GrantTypeName>refresh_token</GrantTypeName>
    <GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.RefreshGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>

您可以像这样扩展 JWT 授权类型并禁用刷新令牌[1]。

AbstractAuthorizationGrantHandler.java

@Override
public boolean issueRefreshToken() throws IdentityOAuth2Exception {
    return false;
}

[1] https://github.com/wso2-extensions/identity-inbound-auth-oauth/blob/master/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AbstractAuthorizationGrantHandler.java#L90