Spring security Spring OAuth2-定制;OAuth批准“;第页oauth/authorize
建议使用什么方法创建自定义页面OAuth Approval page: 我必须完全覆盖页面上的内容,需要添加样式、品牌等。实现这一点的正确方法是什么?我在哪里可以看到默认页面的源代码以将其用作起点Spring security Spring OAuth2-定制;OAuth批准“;第页oauth/authorize,spring-security,spring-security-oauth2,Spring Security,Spring Security Oauth2,建议使用什么方法创建自定义页面OAuth Approval page: 我必须完全覆盖页面上的内容,需要添加样式、品牌等。实现这一点的正确方法是什么?我在哪里可以看到默认页面的源代码以将其用作起点 我还需要覆盖/login页面,但我认为覆盖它的方法将基本相同 推荐的方法是为“/oauth/confirm\u访问”提供一个普通的Spring MVC@RequestMapping。您可以查看默认实现的白标签ApprovalEndpoint。不要忘记在控制器中使用@SessionAttributes
我还需要覆盖/login页面,但我认为覆盖它的方法将基本相同 推荐的方法是为“/oauth/confirm\u访问”提供一个普通的Spring MVC
@RequestMapping
。您可以查看默认实现的白标签ApprovalEndpoint
。不要忘记在控制器中使用@SessionAttributes(“authorizationRequest”)
。除了@DaveSyer之外,它应该适用于大多数情况。有时基于配置和定制,如果Framew,上述方法可能不起作用汉德勒玛酒店Spring Security OAuth包中的ping
的顺序高于应用程序的RequestMappingHandlerMapping
。如果是这种情况,那么servlet dispatcher将永远不会到达您的映射,并且将始终显示默认页面
解决此问题的一种方法是更改映射程序的顺序,因为Framew汉德勒玛酒店ping
的顺序是顺序。最低优先级为-2
另一种方法是将审批页面设置为自定义URL,而不是由Framew映射汉德勒玛酒店ping
,因此servlet dispatcher将到达应用程序的映射
@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthorizationEndpoint authorizationEndpoint;
@PostConstruct
public void init() {
authorizationEndpoint.setUserApprovalPage("forward:/oauth/custom_confirm_access");
authorizationEndpoint.setErrorPage("forward:/oauth/custom_error");
}
}
在这种配置下,
/oauth/custom\u confirm\u access
和/oauth/custom\u error
的映射将分别用作确认页和错误页 使用WebMVCConfiguer
和
凌驾
void addViewController(ViewControllerRegistry注册表)
method
@springboot应用程序
@EnableAuthorizationServer
公共类AuthServerApplication实现WebMVCConfiguer{
公共静态void main(字符串[]args){
run(AuthServerApplication.class,args);
}
@凌驾
public void addViewController(ViewControllerRegistry注册表){
registry.addViewController(“/oauth/confirm_access”).setViewName(“AuthorizationPage”);
}
}
这里的
AuthorizationPage
是您创建的html页面
。是否有其他自定义页面的方法。在我的安装应用程序中,HandlerMapping
的顺序低于org.springframework.security.oauth2.provider.endpoint.FrameworkEndpointHandlerMapping
,因此,自定义映射会在默认映射之后拾取,不会覆盖后者?我认为我不会这样做。您只需在/oauth/confirm_access(或您自定义的端点路径)提供一个资源。你怎么做并不重要。Framew汉德勒玛酒店Ping
的顺序为order.LOWEST_priority-2
,但我的自定义RequestMappingHandlerMapping
的顺序为order.LOWEST_priority
因此org.springframework.web.servlet.DispatcherServlet#getHandler
选择Framew汉德勒玛酒店Ping的映射和请求从未到达我的客户控制器。不幸的是,目前我不能改变订单。我最后做的是authorizationEndpoint.setUserApprovalPage(“forward:/oauth/customer_path”)
;在@PostConstruct
方法的AuthorizationServerConfiguration
中。由于/oauth/customer\u路径
未由框架映射汉德勒玛酒店Ping
,dispatcher到达我的控制器的映射。另外,别忘了将您的控制器更改为具有bean名称,而不是WhitelabelApprovalEndpoint,否则Spring将获得优先权(我最终发现)。。。。。