Apache oltu Oauth2令牌验证

时间:2015-08-18 16:02:46

标签: java rest oauth-2.0 access-token oltu

我需要使用Apache oltu代码验证由oauth .NET应用程序生成的令牌:

OAuthClientRequest oAuthRequest = OAuthClientRequest                        
.tokenLocation("https://URL/idp/connect/identitytokenvalidation")
.setClientId("CLIENTID")        
.setGrantType(GrantType.REFRESH_TOKEN)
.setParameter("token", oauthToken)
.setScope("openid info")
.buildQueryMessage();

OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

OAuthAccessTokenResponse oAuthResponse = oAuthClient.accessToken(oAuthRequest, OAuth.HttpMethod.GET);   

它似乎工作正常,因为我从服务器得到回复(它确认令牌有效或无效)但它不是预期的回复。我们的身份服务器正在以这种方式回复:

auth_time=1439911238, exp=1439911599, sub=300a3657-62f4-4d34-8c60-2c8696780abe, null, null, at_hash=jb6EW9ZgDm60aL573No4sw, null, null, nbf=1439911239, null, null, idp=idsrv, null, iat=1439911239, null, amr=password

但是OAuthAccessTokenResponse验证器引发了一个问题,因为它似乎需要一个令牌,如下所示:

{
  "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSIsImtpZCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSJ9.eyJub25jZSI6IjE0Mzk5MTIxNTI4MjMwLjM0NTUyOTg3MjkyNDA4OTQzIiwiaWF0IjoxNDM5OTEyMTUyLCJhdF9oYXNoIjoiWlItaGlwcGh6YUctSlhkVGRnZTZwQSIsInN1YiI6IjMwMGEzNjU3LTYyZjQtNGQzNC04YzYwLTJjODY5Njc4MGFiZSIsImFtciI6InBhc3N3b3JkIiwiYXV0aF90aW1lIjoxNDM5OTExMjM4LCJpZHAiOiJpZHNydiIsImlzcyI6Imh0dHBzOi8vdWF0Lm1lZGlyZXNvdXJjZS5jb20vaGMvaWRwIiwiYXVkIjoiaGVhbHRoY29ubmVjdGVkcG9ydGFsIiwiZ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e2m1-3z_ZkMlX38zgthsaifbuvGACba2AlHutvxjhhsPnoTxa6R1qMsPGaEduhD6siPOtUFGFrGVqxOYssSHHX0EX2-AUj41dZTADnuInQwlWraaGPAJCLoCI3Ww1BY5wz9-5Eo6pfXtCZFABZL30TVxfvsXZaTrPWgw-WjhEnG0otFtvVAtjN0z4N-0NhISu-dcoX2KhOU26ckp1XC9xiK8sP-6OC0Bf-1Ecrep3Y_uDCOnBRw",
  "token_type": "Bearer",
  "expires_in": "360",
  "scope": "openid info",
  "state": "14399121528230.34552987292408943",
  "session_state": "1hTuAWL5A_Aj-sGFjpFACF4OI-gnyUEgnxcvImTavtw.0fb69b197f167119b7ab2362882938d8"
}

有任何线索吗?验证令牌的网址是使用GET,以便能够使用此方法发送呼叫,我需要接受作为回复 OAuthAccessTokenResponse

我错过了什么吗? 安德烈

1 个答案:

答案 0 :(得分:1)

验证OAuth 2.0令牌的方式不是标准化的。正在开展工作:https://tools.ietf.org/html/draft-ietf-oauth-introspection-11这意味着您的验证实现与您的身份服务器不兼容。

编辑:此作品已在https://tools.ietf.org/html/rfc7662

中标准化