2016-12-14 101 views
0

当登录到Auth0:当通过refresh_token在Auth0,日本烟草国际公司(JWT ID)更新id_token没有新id_token

POST https://my.auth0.com/oauth/ro 
{ 
    "client_id": "<client-id>", 
    "username": "[email protected]", 
    "password": "••••••••", 
    "connection": "<auth0-connection>", 
    "grant_type": "password", 
    "scope":  "openid offline_access jti email", 
    "device":  "<device-id>" 
} 
// Response 
{ 
    "refresh_token": "<refresh-token>", 
    "id_token": "<id-token>", 
    "access_token": "<access-token>", 
    "token_type": "bearer" 
} 
// id_token JWT payload 
{ 
    "jti": "3d4c5e97-3543-4c53-b46e-3aa965cd5a34", 
    "email": "[email protected]", 
    "email_verified": false, 
    "iss": "https://my.auth0.com/", 
    "sub": "auth0|<id>", 
    "aud": "<aud>", 
    "exp": 1481766419, 
    "iat": 1481730461 
} 

如果我指定我的范围jti,返回id_token,这是一个智威汤逊,将包含jti。 Auth0推荐在智威汤逊拥有jtijti s唯一标识智威汤逊,可用于黑名单智威汤逊等事情。

出于某种原因,不过,如果我尝试使用刷新标记获得新的id_token

POST https://my.auth0.com/delegation 
{ 
    "client_id":  "<client-id>", 
    "grant_type":  "urn:ietf:params:oauth:grant-type:jwt-bearer", 
    "refresh_token": "<refresh-token>", 
    "api_type":  "app", 
    "scope":   "openid offline_access jti email", 
    "device":   "<device-id>" 
} 
// Response 
{ 
    "token_type": "Bearer", 
    "expires_in": 35958, 
    "id_token": "<id-token>" 
} 
// id_token JWT payload 
{ 
    "email": "[email protected]", 
    "email_verified": false, 
    "iss": "https://my.auth0.com/", 
    "sub": "auth0|<id>", 
    "aud": "<aud>", 
    "exp": 1481766678, 
    "iat": 1481730720, 
    "azp": "<azp>" 
} 

即使我指定我的范围jti,返回不包含jtiid_token

这是一个错误?请帮忙。

回答

0

jti声明不是默认生成或包含的声明。如果你看到的是行为的最有可能的解释是,你有一个自定义规则是做以下:

function (user, context, callback) { 
    user.jti = require('uuid').v4(); 
    callback(null, user, context); 
} 

这意味着,当你包括价值被包含在最终标识的jti的范围令牌,因为它是从该属性获得的。在通过授权进行时,jti声明似乎得到了特别处理,刷新时忽略它。不鼓励使用委托进行刷新,但是,如果您想继续使用该方法,并且只需要JWT中的唯一标识符,那么如果您使用非保留声明名称,则可以解决此问题。例如,在一条规则中:

function (user, context, callback) { 
    user.myjti = require('uuid').v4(); 
    callback(null, user, context); 
} 

然后在两个请求中都包含myjti作用域;一个快速测试表明,这也适用于使用委托。

+0

谢谢!你是对的,有一个规则设置jti。我应该使用什么端点来使用我的refresh_token获取新的id_token?我使用{grant_type:“refresh_token”,refresh_token:}尝试了https://dev-innit.auth0.com/oauth/token,并得到了不受支持的_grant_type。我宁愿使用正确的端点,而不是创建自己的JWT ID属性。 – enamrik

+0

为了使用授权类型为'refresh_token'的'/ oauth/token',您需要在高级帐户设置中启用* OAuth 2.0 API授权*,然后还可以在客户端启用* OIDC Conformant *标志应用级别。但是,尽管如此,我不认为在刷新令牌端点时目前支持规则,因此您无法将声明添加到该值。目前,自定义声明名称和委派端点的使用是可用的。 –

+0

谢谢,这真的很清楚和直接。我将使用'/ delegation'端点,直到'/ oauth/token'支持自定义声明。 – enamrik