简体   繁体   English

如何从SpringSocial Facebook自定义URL到access_denied?

[英]How can I custom url to access_denied from SpringSocial Facebook?

In ProviderSignInController we have a method oauth2ErrorCallback. ProviderSignInController中,我们有一个方法oauth2ErrorCallback。 When the user cancel authorization in facebook this method redirect to: 当用户在Facebook中取消授权时,此方法重定向到:

/signin?error=access_denied&error_description=Permissions+error

I need customize this url, how can do it? 我需要自定义此网址,该怎么办?

I need redirect to my page, customized. 我需要重定向到定制的页面。

For now, I overrride the ProvidersignInCrontroller, but my feeling say to me that this is not the definitive solution 现在,我已经超越了ProvidersignInCrontroller,但我的感觉对我来说,这不是最终的解决方案

class MyProviderSignInController extends ProviderSignInController {
    private final Logger log = LoggerFactory.getLogger(MyProviderSignInController.class);

    private String urlToOauth2ErrorCallback;

    public MyProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator,
            UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter) {
        super(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
    }

    public void defineUrlToOauth2ErrorCallback(String urlToOauth2ErrorCallback) {
        this.urlToOauth2ErrorCallback = urlToOauth2ErrorCallback;
    }

    @RequestMapping(value = "/{providerId}", method = RequestMethod.GET, params = "error")
    public RedirectView oauth2ErrorCallback(@PathVariable String providerId, @RequestParam("error") String error,
            @RequestParam(value = "error_description", required = false) String errorDescription,
            @RequestParam(value = "error_uri", required = false) String errorUri, NativeWebRequest request) {
        log.warn("Error during authorization: " + error);

        if (urlToOauth2ErrorCallback != null) {
            return new RedirectView(urlToOauth2ErrorCallback, false);
        }

        return super.oauth2ErrorCallback(providerId, error, errorDescription, errorUri, request);
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OAuth2RestTemplate身份验证问题得到access_denied - OAuth2RestTemplate authetication issue getting access_denied 通过SpringSocial获取Facebook用户位置 - facebook user location fetch via SpringSocial 无法验证提供的 CSRF 令牌,因为未找到您的会话。</error_description><error> 访问被拒绝</error></oauth> * - Could not verify the provided CSRF token because your session was not found.</error_description><error>access_denied</error></oauth>* Spring Security,授权访问,拒绝特定URL - Spring Security, authorize access, denied for specific URL URL访问在Grails春季安全性中被拒绝 - URL access denied in grails spring-security 通过自定义身份验证了解Spring Security中的“访问被拒绝” - Understanding “Access Denied” in spring security with custom authentication 如果我使用自定义域名而不是localhost,则jasper服务器会在登录后拒绝访问 - jasper server gives access denied after login if i use custom domain name instead of localhost 如何确定使用Spring Security访问URL所需的角色? - How can I determine what roles are required to access a URL with Spring Security? 如何在没有任何端口的情况下直接使用 url 访问我的 spring 启动 web 应用程序? - How can I directly use url to access my spring boot web application without any port? 如何使用Spring安全性和spring安全对象的属性限制对URL的访问? - How do I restrict access to a URL using Spring security and a property from the spring security object?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM