启用spring授权/资源服务器的登录页面

时间:2016-10-06 16:01:58

标签: spring-security kotlin spring-security-oauth2

我试图让基于OAuth2的SSO与spring一起工作。我创建了一个服务器和客户端,但在启用授权和资源服务器之后,我遇到了一个问题。

@SpringBootApplication
@EnableAuthorizationServer
@EnableResourceServer
open class GsAuthenticationApplication {
    companion object {
        @JvmStatic  fun main(args: Array<String>) {
            SpringApplication.run(GsAuthenticationApplication::class.java, *args)
        }

    }
}

一旦完成连接,生成的/登录页面就不再可用,因为它似乎被视为受保护的OAuth资源

<oauth>
<error_description>
Full authentication is required to access this resource
</error_description>
<error>unauthorized</error>
</oauth>

我创建了一个WebSecurityCOnfigurerAdapter bean,并尝试使用下面的configure方法明确设置它,但它仍然给我同样的问题

override fun configure(http: HttpSecurity?) {
        //super.configure(http)
        // @formatter:off
        http
            ?.authorizeRequests()
            ?.and()
            ?.formLogin()
                ?.loginPage("/login")
                ?.permitAll()
        // @formatter:on

    }

0 个答案:

没有答案
相关问题