@EnableAuthorizationServer was the annotation from the old Spring Security OAuth project that turned a Spring application into an OAuth 2.0 authorization server. That project is deprecated and has reached end of life, so you should not use the annotation in new code. The current replacement is Spring Authorization Server, which is configured with a SecurityFilterChain and a RegisteredClientRepository instead of an annotation.
If you maintain an older application you will still meet @EnableAuthorizationServer, so it helps to know what it did and how each piece maps to the modern setup.
@EnableAuthorizationServer did@EnableAuthorizationServer didThe annotation lived in the spring-security-oauth2 library (package org.springframework.security.oauth2.config.annotation.web.configuration). Placed on a @Configuration class, it imported the machinery for the OAuth 2.0 endpoints:
/oauth/authorize, the authorization endpoint for the authorization code flow/oauth/token, the token endpoint/oauth/check_token, for resource servers to validate opaque tokens/oauth/token_key, to publish a public key for JWT verificationYou customised it by extending AuthorizationServerConfigurerAdapter and overriding configure methods for clients, endpoints and security.
Spring Security OAuth was placed in maintenance mode years ago and later reached end of life, so it receives no security fixes. It does not support Spring Security 6 or Jakarta EE, which means it cannot run on current Spring Boot versions. It also predates modern OAuth 2.1 practice: the implicit grant and the password grant that it supported are discouraged or removed in current guidance.
Spring Security's own OAuth 2.0 support covers the client and resource server roles. The authorization server role moved to the separate Spring Authorization Server project, which is the officially supported path.
Spring Authorization Server implements OAuth 2.1 and OpenID Connect 1.0. Add the dependency org.springframework.boot:spring-boot-starter-oauth2-authorization-server on Spring Boot 3.1 or newer; check the project page for the exact coordinates in newer Boot lines. A minimal configuration looks like this:
You also need a second SecurityFilterChain for login of end users, a UserDetailsService, and a JWKSource bean for signing keys. For simple setups, Spring Boot can register clients from spring.security.oauth2.authorizationserver.* properties without code. Production deployments should store clients and authorizations in a database (JdbcRegisteredClientRepository) and hash secrets with a real PasswordEncoder, not {noop}.
Details of the API move between releases, so confirm method names against the Spring Authorization Server reference for your version.
| Legacy Spring Security OAuth | Spring Authorization Server |
|---|---|
@EnableAuthorizationServer | SecurityFilterChain with OAuth2AuthorizationServerConfigurer |
ClientDetailsService | RegisteredClientRepository |
/oauth/token, /oauth/authorize | /oauth2/token, /oauth2/authorize |
TokenStore | OAuth2AuthorizationService |
| Password and implicit grants | Not supported; use authorization code with PKCE |
Often not. Managed identity providers such as Keycloak, Auth0 or cloud identity services cover token issuing, user management and compliance. Choose Spring Authorization Server when you need tight control or customisation inside a Spring stack.
@EnableAuthorizationServer deprecated?Yes. It belongs to a project that is end of life and incompatible with current Spring Boot releases.
@EnableResourceServer?Spring Security's built-in resource server support, enabled with http.oauth2ResourceServer(...).
No. A resource server only validates tokens issued by some authorization server, which can be external.
Authorization code with PKCE for user-facing clients and client credentials for service-to-service calls.
@EnableAuthorizationServer enabled OAuth 2.0 endpoints in the retired Spring Security OAuth library. For new work use Spring Authorization Server with a SecurityFilterChain and RegisteredClientRepository, or an external identity provider.