AuthProvider#
com.zitlab.palmyra.store.base.security.AuthProvider
Overview#
Tiny SPI for resolving the currently authenticated user. Provide an implementation (typically wired against your auth stack — Spring Security, an OAuth filter, a JWT resolver) and the storage layer will call getUser() to stamp audit columns, scope ACLs, and so on. A lightweight SimpleUserProvider is available for tests and fixtures via the of(String) factory.
Methods#
| Method | Signature |
|---|---|
getUser |
String getUser() |
of |
static AuthProvider of(String user) — returns a SimpleUserProvider |
Example#
@Component
public class SecurityContextAuthProvider implements AuthProvider {
@Override
public String getUser() {
var auth = SecurityContextHolder.getContext().getAuthentication();
return (auth != null && auth.isAuthenticated()) ? auth.getName() : "anonymous";
}
}
// Unit / integration tests — fixed user:
AuthProvider fixture = AuthProvider.of("test-user");