領先一步
VMware 提供培訓和認證,以加速您的進展。
了解更多Spring Security OAuth 2.0.0.RC1 現在可從 Spring Repo 取得。 這是 Spring 上 OAuth 伺服器和用戶端應用程式邁向現代化和易用性的一大步。
最主要的功能是支援 @Configuration
(僅適用於 OAuth2),如果您使用 Spring Boot 編寫應用程式,您可以用大約 25 行程式碼來提供 Token 並保護 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) Token,並且還有一個明確的 Approvals 網域用於管理和持久化使用者授權。 這些功能大量參考了 CloudFoundry UAA 的工作。
Authorization Server API 已被大量重構,以便輕鬆新增新的使用案例:例如 OpenID Connect (OIDC)、MAC Token 或新的 Token Revocation 標準都很容易新增。 我知道至少有一個 OIDC 實作已經在使用 Spring OAuth2 2.0。
非常感謝許多人在這項工作中的幫助,但我們自己的 Rob Winch 應該受到大大的讚揚,因為他讓 @Configuration
的工作順利啟動。 在 2.0 的開發過程中,我們將所有內容(包括問題追蹤)都轉移到了 github,我認為這帶來了更多的社群參與,因此這次的許多貢獻者都直接來自於使用該軟體的人,這非常棒。 感謝所有提供幫助的人!