栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Spring Security OAuth2简单配置

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring Security OAuth2简单配置

不要让sparklr样本使您感到困惑(它所做的远远超出您的预期)。就是这个简单的够吗?

@ComponentScan@EnableAutoConfigurationpublic class Application {public static void main(String[] args) {    SpringApplication.run(Application.class, args);}@Configuration@Order(Ordered.LOWEST_PRECEDENCE - 100)protected static class OAuth2Config extends OAuth2AuthorizationServerConfigurerAdapter {    @Override    protected void configure(AuthenticationManagerBuilder auth) throws Exception {        // @formatter:off        auth.apply(new InMemoryClientDetailsServiceConfigurer()) .withClient("my-trusted-client")     .authorizedGrantTypes("password", "authorization_pre", "refresh_token", "implicit")     .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")     .scopes("read", "write", "trust")     .accessTokenValiditySeconds(60)        .and() .withClient("my-client-with-secret")     .authorizedGrantTypes("client_credentials")     .authorities("ROLE_CLIENT")     .scopes("read")     .secret("secret");    // @formatter:on    }}}

那就是认证服务器。客户端也很容易(例如Spring OAuth项目中的客户端)。PS这是Spring
OAuth 2.0的全部内容(尚未发布),但是我们正在努力(而XML配置的1.0功能确实没有那么重)。

注意:这种方式击败了OAuth2的对象(Webapp客户端
应该收集用户凭据)。您应该考虑使用

grant_type=authorization_pre



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/670798.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号