Interface AuthenticationRule
AuthenticationRule can authorize any request against our RESTful service.
The rule is called if a client does not transmit a JSESSIONID (cookie).
If there is more than one rule of this type, they are called in order of javax.annotation.Priority.
A thrown exception cancels the request directly. If the result of the rule is null or the username and userId are null,
the next one is called.
By default, the session is dropped after the request. If a client supports login (store and transmit the JSESSIONID cookie),
you should enable the Nuclos login for the user by adding .withLoginRequired(true) to the result.
A login always requires a logout from the client after the work is done.
Are many requests expected and the authentication is a complex process (SSO token check, for example),
a login is recommended, or at least caching some relevant information within the rule.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionauthenticate(AuthenticationContext context) default booleanA session with login whose lifetime has expired will call this method next time a request starts.default booleanvalidateUserInfo(ValidateUserInfoContext context) Directly with the Sso authentication, the Sso server returns information about the user.
-
Method Details
-
authenticate
- Parameters:
context-AuthenticationContextis the context providing all authorization-relevant attributes, such as all header information and the called URL.- Returns:
- A successful authentication must identify a user. A minimum return should look like this:
return AuthenticationResult .builder() .withUsername("nuclos") .build(); - Throws:
BusinessException
-
refreshAuthentication
default boolean refreshAuthentication(RefreshAuthenticationContext context) throws BusinessException A session with login whose lifetime has expired will call this method next time a request starts.The lifetime can be set in the result. The default is
null, which means that the system is handling the session only and a refresh is never called.- Parameters:
context-RefreshAuthenticationContextis the context providing all refresh-relevant attributes, similar to theAuthenticationContextbut with theAuthenticationResultfor the current session. You can save important values from the authentication as attribute in the result.withAttribute("myAttr", "myValue")- Returns:
truewhen refresh was successful,falseotherwise. Afalseautomatically results in a logout.- Throws:
BusinessException
-
validateUserInfo
Directly with the Sso authentication, the Sso server returns information about the user.By the method this information can be validated. If it returns false, the user cannot log in.
- Parameters:
context-ValidateUserInfoContextis the context providing the user information and the nuclos userId if it has been successfully mapped.- Returns:
truewhen validation was successful,falseotherwise. Afalseautomatically results in a logout.- Throws:
BusinessException
-