Interface CsrfTokenGenerator<T>
- Type Parameters:
T- Request
- All Known Subinterfaces:
CsrfHmacTokenGenerator<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@DefaultImplementation(io.micronaut.security.csrf.generator.DefaultCsrfTokenGenerator.class)
@FunctionalInterface
public interface CsrfTokenGenerator<T>
CSRF token Generation.
- Since:
- 4.11.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescription@NonNull StringgenerateCsrfToken(T request) Generates a CSRF Token.default @NonNull StringgenerateCsrfToken(T request, @Nullable Authentication authentication) Generates a CSRF Token bound to the supplied authenticated user.
-
Method Details
-
generateCsrfToken
Generates a CSRF Token.- Parameters:
request- Request- Returns:
- A CSRF Token.
-
generateCsrfToken
@NonNull default @NonNull String generateCsrfToken(@NonNull T request, @Nullable @Nullable Authentication authentication) Generates a CSRF Token bound to the supplied authenticated user. Use this method when the request does not carry the authentication yet, for example while handling a login. The default implementation ignores the authentication and delegates togenerateCsrfToken(Object).- Parameters:
request- Requestauthentication- The authenticated user's representation ornullfor an anonymous request- Returns:
- A CSRF Token.
- Since:
- 4.18.2
-