Package io.micronaut.security.utils
Interface SecurityService
- All Known Implementing Classes:
 DefaultSecurityService
public interface SecurityService
Provides a set of convenient methods related to authentication and authorization.
- Since:
 - 1.0
 - Author:
 - Sergio del Amo
 
- 
Method Summary
Modifier and TypeMethodDescriptionRetrievesAuthenticationif authenticated.booleanIf the current user has a specific role.booleanCheck if a user is authenticated.username()Get the username of the current user. 
- 
Method Details
- 
username
Get the username of the current user.- Returns:
 - the username of the current user or Optional.empty if not authenticated
 
 - 
getAuthentication
Optional<Authentication> getAuthentication()RetrievesAuthenticationif authenticated.- Returns:
 - the 
Authenticationof the current user 
 - 
isAuthenticated
boolean isAuthenticated()Check if a user is authenticated.- Returns:
 - true if the user is authenticated, false otherwise
 
 - 
hasRole
If the current user has a specific role.- Parameters:
 role- the role to check- Returns:
 - true if the current user has the role, false otherwise
 
 
 -