我有一个SAP试用帐户,并且我正在Cloud Foundry上开发一个带有Spring Boot后端的SAP ui5应用程序。我还有一个用于身份验证/授权以及访问我的应用程序的应用程序路由器。我有一个简单的页面index.html,上面有一个按钮,它调用我的spring后端(“ / hello”),并在其上有一个注销按钮(“ / my / logout”)。
我在这篇文章中给出的所有链接只能通过approuter来访问(/index.html、/hello和/ debug都是“ https://approuter-p *** trial.cfapps.eu10.hana.ondemand的相对路径。 .com”)。
这是我正在做的一系列事件,这让我感到困惑:
我还检查了通过打印它的“ / debug”后端接收到的令牌,似乎注销后,直接从浏览器(而不是从index.html或POSTMAN)对spring后端的任何调用都会收到一个新的JWT令牌,这似乎是有效的。我注意到的唯一区别是200个响应带有标题“ X-Frame-Options:DENY”,而401个响应带有标题“ X-Frame-Options:SAMEORIGIN”。对此进行了Chrome和IE的测试-两者的行为相同。
有什么想法为什么会这样?我的xs-app.json(由my-xsuaa服务使用,并由approuter使用):
{
"welcomeFile": "index.html",
"authenticationMethod" : "route",
"routes": [{
"source": "/",
"target": "/",
"destination": "app-destination-hello"
}],
"logout": {
"logoutEndpoint": "/my/logout"
},
"destinations": {
"app-destination-hello": {
"logoutPath": "/myrest/logout",
"logoutMethod": "GET"
}
}
}
谢谢!
我将附加来自approuter的一些跟踪信息,也许有帮助。这些是我对相应日志采取的步骤(在步骤之间没有跳过任何日志条目):
我按下了index.html中的注销按钮:
2018-08-31T15:37:50.63 + 0300 [APP / PROC / WEB / 0] OUT#2.0#2018 08 31 12:37:50:632#+ 00:00#ERROR#/ Handler ### ######-UTzTjYczINpXSxkJY_QXoWlfSF3dk0O ###### jlhzhep3#PLAIN ## GET对/ my / logout的请求以状态401完成-需要验证# 2018-08-31T15:37:50.63 + 0300 [RTR / 7] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:37:50.632 + 0000]“ GET / my / logout HTTP / 1.1“ 401 0 12” https://approuter-p *** trial.cfapps.eu10.hana.ondemand.com/index.html“” Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit /537.36(KHTML,如Gecko)Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” bb472547-cf0f-407d-6ccb-87d“ 2dd42d4e7 response_time:0.002667543 app_id:“ 9ceaf8d0-7ee7-4fb2-84d0-05df07af7c01” app_index:“ 0” x_b3_traceid:“ 56fc90749079fa0f” x_b3_spanid:“ 56fc90749079fa0f” x_b3_parentspanid:“- 2018-08-31T15:37:50.63 + 0300 [RTR / 7] OUT
我按下了index.html中的spring按钮(端点名称现在为/ hello2,但与之前相同),我收到了401,这是可以的:
2018-08-31T15:37:57.57 + 0300 [APP / PROC / WEB / 0] OUT#2.0#2018 08 31 12:37:57:575#+ 00:00#ERROR#/ Handler ### ###### utCeM-9IrqFW7oEOGkqMtIoUmwgTpZsv ###### jlhzhk1z#PLAIN ## GET请求到/ hello2的请求已完成,状态为401-需要验证# 2018-08-31T15:37:57.58 + 0300 [RTR / 4] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:37:57.583 + 0000]“ GET / hello2 HTTP / 1.1“ 401 0 12” https://approuter-p *** trial.cfapps.eu10.hana.ondemand.com/index.html“” Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36 (KHTML,例如Gecko)Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” 600551f2-7054-4d08-68aa-75d88f2584e2“响应时间: 0.003231487 app_id:“ 9ceaf8d0-7ee7-4fb2-84d0-05df07af7c01” app_index:“ 0” x_b3_traceid:“ 25c2df6333a965cf” x_b3_spanid:“ 25c2df6333a965cf” x_b3_parentspanid:“-” 2018-08-31T15:37:57.58 + 0300 [RTR / 4] OUT
我从另一个浏览器选项卡打开approuter / hello2链接,并收到200(挪威克朗)的提示: 2018-08-31T15:38:00.79 + 0300 [APP / PROC / WEB / 0] OUT#2.0#2018 08 31 12:38:00:797#+ 00:00#INFO#/ Auth / OAuth2 ##### ##### pPyrBRKTJWcfwzc8yP8EExMmQbCfW992 ##### jlhzhmjg#PLAIN ##将客户端发送页面重定向到https://p *** trial.authentication.eu10.hana.ondemand.com/oauth/authorize?response_type = code&client_id = sb-firstapp3cris!t5664&redirect_uri = https%3A%2F%2Fapprouter-p *** trial.cfapps.eu10.hana.ondemand.com%2Flogin%2Fcallback# 2018-08-31T15:38:00.80 + 0300 [RTR / 5] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:38:00.801 + 0000]“ GET / hello2 HTTP / 1.1“ 200 0 483” https://approuter-p *** trial.cfapps.eu10.hana.ondemand.com/hello2“” Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML ,例如Gecko)Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” 5e18d1e8-f7e6-4b21-6f6a-2a7ea386cidcc“ 700_app_time :“” 9ceaf8d0-7ee7-4fb2-84d0-05df07af7c01“ app_index:” 0“ x_b3_traceid:” 89e2fc6581f0c47b“ x_b3_spanid:” 89e2fc6581f0c47b“ x_b3_parentspanid:”-“ 2018-08-31T15:38:00.80 + 0300 [RTR / 5] OUT
以某种方式自动调用登录名(我在index.html选项卡中看到一个调用,但是当我按下注销按钮时就完成了调用,也没有要求您输入用户名/密码的页面): 2018-08-31T15:38:39.46 + 0300 [RTR / 5] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:38:39.158 + 0000]“ GET / login / callback?code = UL6niGFX3T HTTP / 1.1“ 302 0 0” https://p *** trial.authentication.eu10.hana.ondemand.com/login“” Mozilla / 5.0(Windows NT 10.0; Win64; x64 )AppleWebKit / 537.36(KHTML,例如Gecko)Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” 307eee0f-123f-46f6-7102- 9ef370d66ab5“ response_time:0.307257726 app_id:” 9ceaf8d0-7ee7-4fb2-84d0-05df07af7c01“ app_index:” 0“ x_b3_traceid:” a9a073166c04301f“ x_b3_spanid:” a9a073166c04301f“ -pand:” 2018-08-31T15:38:39.46 + 0300 [RTR / 5] OUT
我从approuter / index.html按下了我的弹簧按钮,现在我在这里也收到200条响应: 2018-08-31T15:38:39.70 + 0300 [RTR / 1] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:38:39.542 + 0000]“ GET / hello2 HTTP / 1.1“ 200 0 85” p *** trial.authentication.eu10.hana.ondemand.com/login“” Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML,like Gecko) Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” b6400e34-87c0-47ea-4335-46d9c9348802“ response_time:0.158048749 app_d:af-0 7ee7-4fb2-84d0-05df07af7c01“ app_index:” 0“ x_b3_traceid:” eb6dde02e73d9c38“ x_b3_spanid:” eb6dde02e73d9c38“ x_b3_parentspanid:”-“ 2018-08-31T15:38:39.70 + 0300 [RTR / 1] OUT 2018-08-31T15:38:52.91 + 0300 [RTR / 0] OUT approuter-p *** trial.cfapps.eu10.hana.ondemand.com-[2018-08-31T12:38:52.897 + 0000]“ GET / hello2 HTTP / 1.1“ 200 0 85” approuter-p *** trial.cfapps.eu10.hana.ondemand.com/index.html“” Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML ,例如Gecko)Chrome / 68.0.3440.106 Safari / 537.36“”-“” 10.0.137.79:61038“ x_forwarded_for:”-“ x_forwarded_proto:” https“ vcap_request_id:” a29c59b9-ba64-4249-74ac-dbf9cf6b1255“ response_time:0.0144 ::“ 9ceaf8d0-7ee7-4fb2-84d0-05df07af7c01” app_index:“ 0” x_b3_traceid:“ b16f601b3276909a” x_b3_spanid:“ b16f601b3276909a” x_b3_parentspanid:“-” 2018-08-31T15:38:52.91 + 0300 [RTR / 0] OUT
答案 0 :(得分:2)
给出您的xs-app.json
和approuter URL,我推断注销位于后面:
https://approuter-p***trial.cfapps.eu10.hana.ondemand.com/my/logout。
您是否正在呼叫此端点以从approuter中注销?这会使您的所有会话以及JWT暂时保存在approuter内存中的功能失效。
此外,当您直接访问Spring后端时,您应该始终收到4xx错误代码,因为实际上没有客户端有任何JWT来访问受Spring保护的后端。另外,对基于Spring的后端的访问应独立于任何cookie或会话,因为使用的JWT在设计上是无状态协议。维护的唯一会话cookie是在客户端和approuter之间。
有关此详情,请参阅Extending SAP S/4HANA Book, Chapter 5。