我试图让oauth2与spring-boot一起工作并保护我的休息方法调用,取得了很大的成功 . 我尝试过使用spring-security-oauth2-javaconfig:1.0.0.CI-SNAPSHOT和rg.springframework.boot:spring-boot-starter-security:1.0.0.RC1 .
- gradle:compile(“org.springframework.boot:spring-boot-starter-security:1.0.0.RC1”)
compile ('org.springframework.security.oauth:spring-security-oauth2-javaconfig:1.0.0.CI-SNAPSHOT'){
exclude module: 'spring-security-config'
exclude module: 'spring-security-core'
exclude module: 'spring-security-web'
}
目前我只是想让身份验证和资源服务器正常工作 . 我已复制并尝试修改spring-security-oauth2-javaconfig示例中的现有sparklr2示例 .
我得到的最后一个错误是:“error”:“invalid_client”,“error_description”:“当我运行curl -v时,客户端凭据错误--data”grant_type = password&username = marissa&password = koala&client_id = tonr&secret = secret“-X POST localhost: 8100 /的OAuth /令牌 .
我从初学者的角度理解oauth2,而oauth2与spring-boot和rest相关的资源很少,这让人很难 . 有什么建议?
如果有人可以提供类似于配置oauth2身份验证和授权的方法来保护rest api调用以及相关的curl命令,那将是非常棒的 .
2 回答
oauth2的Java配置支持正在进行中,但使用my fork可能会获得更多成功 . 如果我是你,我bootified sparklr2用最小的XML . 如果您将引导依赖项更新为1.0.0.RC2,我的状态将会很糟糕 .
更新:
@Configuration
内容已移至主OAuth2 repo,因此fork及其父级现在基本上是冗余的(很可能很快就会删除) .更新:启动的示例现在也使用
@Configuration
.是 . 这就是我为了让它以这种方式工作所做的 . 我相信这是正确的解决方案(除了使用client_credentials for grant_type,但我不是专家:-)如果有更好的解决方案,那将是非常棒的 . 非常感谢您花时间帮助我 .