Spring Security
Authentication
Access established identity and authentication state; do not trust raw client identity. Boot 4.0.10 / Security 7.0.9 companion project; source-reviewed, not executed.
Formal Syntax & Structure
java syntaxjava
actor.getName()Working Example
Example Snippetjava
package example.tenant;import java.util.Map;import org.springframework.security.core.Authentication;import org.springframework.stereotype.Component;@Component("tenantAccess")public class TenantAccess { private final Map<String,String> membership = Map.of("alice","north","bob","south"); public boolean allowed(Authentication actor, String tenant) { return actor != null && actor.isAuthenticated() && tenant != null && tenant.equals(membership.get(actor.getName())); }}