Spring Security OAuth 2.0.0.RC1 釋出

釋出 | Dave Syer | 2014 年 4 月 18 日 | ...

Spring Security OAuth 2.0.0.RC1 現在可以從 Spring Repo 獲取。 這對於 Spring 上的 OAuth 伺服器和客戶端應用程式的現代化和易用性來說是向前邁出的一大步。

最主要的功能是支援 @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 的工作。

Authorization Server 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 社群中所有即將舉行的活動。

檢視全部