AuthCore is a Spring Boot library that provides a configurable authentication layer supporting:
- JWT (stateless) authentication with access/refresh tokens
- Optional refresh-token cookies (HttpOnly, SameSite, Secure)
- Session (stateful) authentication using Spring Session
- White-label endpoints for login, refresh, and logout that can be enabled/disabled per application properties
- A simple SPI to add custom JWT claims
It is designed to be embedded as a dependency in client apps. Clients choose their auth mode and behavior using only application.yml—no code changes required. Clients may also disable the built-in endpoints and implement their own controllers while reusing AuthCore services.
- Java 17+
- Spring Boot 3.4.x
- A
UserDetailsServicebean in the client application - For session mode with JDBC store:
spring-session-jdbcand a datasource
<dependency>
<groupId>io.github.flycatch</groupId>
<artifactId>authcore</artifactId>
<version>1.0.0</version>
</dependency>AuthCore is a library (no
main), published for use in other Spring Boot apps.
- Add the dependency above.
- Ensure your app provides a
UserDetailsServicethat can load users by username or email. - Pick your auth mode in
application.yml:- JWT mode (stateless):
auth.jwt.enabled: true,auth.session.enabled: false - Session mode (stateful):
auth.session.enabled: true,auth.jwt.enabled: false
- JWT mode (stateless):
- (JWT mode) Provide a Base64-encoded 256-bit secret.
Run the app. The white-label endpoints are auto-configured and available under /auth/* when enabled.
AuthCore is driven entirely by configuration. All properties live under the auth prefix.
auth:
jwt:
enabled: true
secret: "base64Url_32byte_key_here"
access-token-expiration: 86400000
refresh-token-expiration: 604800000
refresh-token-enabled: true
session:
enabled: false
cookies:
enabled: true
name: "AuthRefreshToken"
http-only: true
secure: false
same-site: "Strict"
max-age: 604800
logging:
enabled: true
endpoints:
login-enabled: true
refresh-enabled: true
logout-enabled: truespring:
datasource:
url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
username: sa
password:
jpa:
hibernate:
ddl-auto: update
show-sql: true
session:
store-type: jdbc
jdbc:
initialize-schema: always- SecurityFilterChain
- PasswordEncoder:
BCryptPasswordEncoder. - AuthCoreConfig: binds all
auth.*properties. - Controllers (white-label) if enabled:
POST /auth/loginPOST /auth/refresh(JWT mode)POST /auth/logout
- Services
AuthService
{ "username": "testuser", "password": "testpass" }{ "refreshToken": "..." }{ "message": "LOGOUT_SUCCESS" }@Component
public class AppJwtClaimsProvider implements JwtClaimsProvider {
@Override
public Map<String, Object> extractClaims(UserDetails user) {
Map<String, Object> claims = new HashMap<>();
claims.put("username", user.getUsername());
return claims;
}
}Disable endpoints and call AuthService directly.
- Permit
/auth/** - JWT mode uses
JwtAuthFilter - Session mode persists in
HttpSession
LoginRequestRefreshRequestAuthResponseMessageResponse
curl -i -X POST "http://localhost:8080/auth/login" -H "Content-Type: application/json" -d '{ "username": "testuser", "password": "testpass" }' -c cookies.txtcurl -i -X POST "http://localhost:8080/auth/login" -H "Content-Type: application/json" -d '{ "username": "testuser", "password": "testpass" }' -c cookies.txt- Java 17
- Spring Boot 3.4.2
- JJWT 0.11.5
Fork, clone, build with Maven.
AuthCore is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for details.