在Spring OAuth2中禁用确认页面
作者:互联网
我正在通过分解three interconnected sample apps at this GitHub link集来研究Spring OAuth2.这些应用程序可以在我的devbox上按预期工作,但是authserver应用程序生成了一个不需要的确认页面,该页面要求用户确认他们在localhost:8080 / login上授权客户端以接收其内容.受保护的信息.确认页面的屏幕截图如下:
需要对authserver应用程序的代码进行哪些特定更改以删除确认步骤?
我了解确认页面在某些用例中可能会有用.但是确认页面不适用于我想到的用例,那么如何禁用此步骤?
第一次尝试:
我在authorize.ftl
, which you can read by clicking on this link中找到了授权页面的查看代码.但是,当我在Eclipse工作区中执行Ctrl-H并搜索“ authorize.ftl”时,没有任何结果显示.同样,我查看了Spring OAuth2 Developer Guide.该指南中提到了创建单独的@RequestMappig(“ / oauth / authorize”),但似乎不清楚如何禁用此确认步骤.
模板登录视图的代码在login.ftl
, which you can read at this link中.
是否可以简单地将login.ftl代码移动到新的login.html文件中,然后使用@RequestMappig(“ / oauth / authorize”)管理该视图的解决方案?
如果我从上面的开发人员指南链接正确地解释了工作原理,似乎是在说
1.)链接到GET的@RequestMappig(“ / oauth / authorize”)方法将提供登录视图,然后提供另一个@RequestMappig(“ / oauth / authorize”),
2.)然后链接到POST的另一个@RequestMappig(“ / oauth / authorize”)方法将从视图中获取信息并绕过确认步骤.
但是,这在代码中会是什么样?如果我正确理解,这是一个起点:
`@RequestMappig("/oauth/authorize", method = RequestMethod.GET)`
public @ResponseBody SomeType method1Name(){
SomeType st = new SomeType();
//do some stuff to st
return st;
}
`@RequestMappig("/oauth/authorize", method = RequestMethod.POST)`
public @ResponseBody SomeType method2Name(){
SomeType st = new SomeType();
//do other stuff to st
return st;
}
我要输入什么方法?然后我放视图代码了吗?
开发人员指南说从WhiteLabelApprovalEndpoint,java
, which you can read on GitHub at this link开始.
解决方法:
用户对令牌授予的确认是可选的.如果要跳过该步骤,则需要将客户端注册为autoapprove =“ *”.我很确定这在用户指南中.
标签:spring,spring-boot,spring-mvc,spring-security,spring-oauth2 来源: https://codeday.me/bug/20191009/1878442.html