SpringSecurityOauth2的授权服务器也支持通过yaml配置文件来配置,不过其token的存储方式只能是基于内存和JWT方式。无需你编写授权服务器配置类。
@EnableAuthorizationServer@SpringBootApplicationpublic class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}}
只需要以上方式加上SpringSecurity的一个配置类就可以。<br /><br />最后展示一下Yaml的配置:
security:oauth2:client:client-id: gaoxiclient-secret: "123456"access-token-uri: http://www.baidu.comscope: read,writeauthorized-grant-types: client_credentials,password,refresh_tokenauthorization:token-key-access: permitAll()check-token-access: permitAll()jwt:key-value: 123456
这样就可以使用了。
