Spring Security OAuth 2.0.0.RC1 已发布

版本发布 | Dave Syer | 2014 年 4 月 18 日 | ...

现在可以从 Spring Repo 获取 Spring Security OAuth 2.0.0.RC1。这是朝着 OAuth 服务器和 Spring 上的客户端应用程序现代化和易用性方向迈出的重要一步。

最主要的特性是支持 @Configuration(仅限 OAuth2),如果您使用 Spring Boot 编写应用程序,可以在大约 25 行代码中提供令牌并保护 API 资源。

@Configuration
@EnableAutoConfiguration
@EnableResourceServer
@RestController
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@RequestMapping("/")
	public String home() {
		return "Hello World";
	}

	@Configuration
	@EnableAuthorizationServer
	protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter {

		@Autowired
		private AuthenticationManager authenticationManager;
		
		@Override
		public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
			endpoints.authenticationManager(authenticationManager);
		}
		
		@Override
		public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
		 	clients.inMemory()
		        .withClient("my-trusted-client")
		            .authorizedGrantTypes("password", "authorization_code", "refresh_token")
		            .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
		            .scopes("read", "write", "trust")
		            .resourceIds("oauth2-resource")
		            .secret("secret");
		}

	}

}

我们现在开箱即用地支持 JSON Web Token (JWT) 令牌,并且还有一个明确的 Approvals 域用于管理和持久化用户审批。这些功能在很大程度上借鉴了 CloudFoundry UAA 的工作。

授权服务器 API 进行了大量重构,以便轻松添加新的用例:例如,OpenID Connect (OIDC)、MAC 令牌或新的令牌撤销标准都可以轻松添加。据我所知,至少有一个 OIDC 实现已经在使用 Spring OAuth2 2.0。

有很多人值得感谢,感谢他们在这次工作中提供的帮助,但我们自己的 Rob Winch 值得大声赞扬,他通过 @Configuration 工作启动了这项工作。在 2.0 的开发过程中,我们将包括问题跟踪在内的所有内容都迁移到了 github,我认为结果是社区参与度更高了,因此这次的贡献者中有许多是直接来自使用该软件的人,这很棒。感谢所有提供帮助的人!

获取 Spring 新闻通讯

通过 Spring 新闻通讯保持联系

订阅

领先一步

VMware 提供培训和认证,助您加速进步。

了解更多

获得支持

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件,只需一份简单的订阅。

了解更多

即将举行的活动

查看 Spring 社区所有即将举行的活动。

查看所有