Interface IAuthentication
- All Known Subinterfaces:
ISagaDefaultAuthentication
,ITokenAuthentication
This class will be instantiated very early, to allow for it to add additional space-level configurations.
Because of this it is EXTREMELY IMPORTANT that any injected dependencies are either without side
effects, such as configuration files, or are injected as a Provider
to avoid any potential
issues with the instantiation order of the class.
You can use IAuthenticationSession
to manage sessions. Otherwise, You can also use your own session manager.
With the method authenticate(IAuthenticationRequest, IAuthenticationResponse, IAuthenticationSession)
you
can create your own authentication.
In case you are using 3rd party authentication providers you can use this method to integrate with them.
To create a valid authentication you need to provide a user with a valid role, otherwise Saga will assume that the user doesn't have any permissions.
You can also manage the signout of a user by implementing the method
signOut(IAuthenticationRequest, IAuthenticationResponse, IAuthenticationSession)
.
Here, if you are using Saga session manager, you are advised to invalidate the session
$IAuthenticationSession.invalidate()
.
Register your implementation using api().authentication() in the ioc-interface.
-
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(IAuthenticationRequest req, IAuthenticationResponse resp, IAuthenticationSession session) Implementation of the custom authentication.void
configureIntoSpace
(ISpaceExtensionPointIoc spacesIoc) Will be invoked by Saga Core when the space is done configuring and the authentication implementation is known to allow the authentication implementation a way to manipulate the space configuration.void
configureUserMenu
(IContextMenu userMenu, User loggedInUser) Will be invoked by Saga Core when the Saga UI is to be rendered to allow the authentication implementation a way to manipulate the top right corner user menu.getUsers
(Class<? extends SpaceExtensionContext> space) Get all users in the space.void
signOut
(IAuthenticationRequest req, IAuthenticationResponse resp, IAuthenticationSession session) Implementation of the custom sign out.
-
Method Details
-
authenticate
Optional<User> authenticate(IAuthenticationRequest req, IAuthenticationResponse resp, IAuthenticationSession session) Implementation of the custom authentication. This method will be called for every request made to protected endpoints, and when logging in using Saga UI.- Parameters:
req
- authentication requestresp
- authentication responsesession
- saga session manager- Returns:
- authenticate user
-
signOut
void signOut(IAuthenticationRequest req, IAuthenticationResponse resp, IAuthenticationSession session) Implementation of the custom sign out.- Parameters:
req
- authentication requestresp
- authentication responsesession
- saga session manager
-
configureUserMenu
Will be invoked by Saga Core when the Saga UI is to be rendered to allow the authentication implementation a way to manipulate the top right corner user menu.- Parameters:
userMenu
- the user menu to manipulateloggedInUser
- the user currently logged in
-
configureIntoSpace
Will be invoked by Saga Core when the space is done configuring and the authentication implementation is known to allow the authentication implementation a way to manipulate the space configuration.This is used to add pages and API endpoints needed for the authentication implementation, as normally modules can only configure into the core space unless explicitly configured in the solution configuration.
This will be called exactly once for each space the authentication implementation is configured into, including the core space, if applicable.
- Parameters:
spacesIoc
- the space configuration
-
getUsers
Get all users in the space.- Parameters:
space
- the space to get users from- Returns:
- list of users
-