How to customize the OAuth2 login redirection endpoint base uri with Spring Security Webflux

流过昼夜 提交于 2021-01-29 10:13:33

问题


Spring security in the servlet stack ( web ) allows you to customize the OAuth2 login redirection endpoint base uri in the Oauth2 authorization code grant flow as given here. I am trying to do the same for the reactive stack with Spring webflux. The github issue here mentions an authorizationRequestResolver and authenticationMatcher on the Oauth2LoginSpec that can be used to customize the base uri but I am unable to figure out how. Can someone please help me out with the configuration?


回答1:


In WebFlux applications you can use the authenticationMatcher().

http
    .authorizeExchange(exchanges -> exchanges
        .anyExchange().authenticated()
    )
    .oauth2Login(oauth2 -> oauth2
        .authenticationMatcher(new PathPatternParserServerWebExchangeMatcher("/login/oauth2/code/{registrationId}"))
    );


来源:https://stackoverflow.com/questions/64429271/how-to-customize-the-oauth2-login-redirection-endpoint-base-uri-with-spring-secu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!