2016-12-14 35 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

相關問題