CAS与OpenID Connect - 如何使用“?”设置重定向URI参数代替“#”回调

问题描述:

后,我有CAS与OIDC安装,我已经下面增加一个服务,它的正常工作:CAS与OpenID Connect - 如何使用“?”设置重定向URI参数代替“#”回调

{ 
     "implicit": true, 
     "logoutType": "BACK_CHANNEL", 
     "@class": "org.apereo.cas.services.OidcRegisteredService", 
     "evaluationOrder": 1, 
     "clientId": "TEST", 
     "bypassApprovalPrompt": true, 
     "jsonFormat": true, 
     "jwks": "file:\/etc\/cas\/jwks\/\/enc-test-42.pub.jwks", 
     "signIdToken": true, 
     "description": "Test", 
     "generateRefreshToken": true, 
     "idTokenEncryptionEncoding": "A128GCM", 
     "name": "Test client", 
     "clientSecret": "TEST", 
     "id": 42, 
     "idTokenEncryptionAlg": "RSA-OAEP-256", 
     "scopes": ["java.util.HashSet", ["openid", "profile", "email", "address", "phone"]], 
     "serviceId": "https:\/\/redirect-host/callback", 
     "encryptIdToken": true 
    } 

为了使用CAS登录,我打电话这个网址:

http://cas-server/oidc/authorize?response_type=id_token+token&client_id=TEST&redirect_uri=https:\/\/redirect-host/callback&scope=openid+profile+email+phone+address 

登录工作正常,但是从CAS重定向到回调url之后,accessToken会以“#”不是“?”附加到回调URL中。

https://redirect-host/callback#accessToken=..... 

我可以更改“#”为“?”吗? ? 我需要有参数?以便我可以在回调服务器中读取它们。 (例如在PHP中使用$ _GET)

在CAS源代码中,我发现重定向URL正在构建在“OAuth20TokenAuthorizationResponseBuilder.java”中。

请指教。

我并不是OIDC专家,但是URI中的一个片段标识符。据wikipedia应该

客户不应该URI片段发送到服务器时,他们检索文档,并没有从本地应用程序的帮助(见下文)片段不参与HTTP重定向。

您可以在OIDC规范中找到更多信息。 chapter 15.5.3 of OIDC specification中有一个java脚本示例,如何在片段标识符后提取信息。

您需要研究OIDC协议以了解response_type=id_token+token的含义,为什么要调用它,然后您需要研究implicit:true的作用以及为什么确实将其设置为true。

总之,您选择的机制只需要使用#。切换到不同的响应/授权类型,然后您可以利用查询字符串等。