Custom users authentication against own authority using a JWT token as Bearer authentication.
Adapptio allows you to set your own authorization process and manage the users yourself. There are several steps you need to do.
- 1.Create integration to your authority backend
- 2.Add actions for login, logout and getting current user profile
- 3.Change Auth type in App Configuration
- 4.Setup login page
Add integration to your authority backend, it will be a REST API or a GraphQL in most cases.
First it is important to disable authenticated user check for this action.
Add parameters acording to your API specification, probably a username and a password.
- username / email (settings: string, required)
- password (settings: password, required)
Then add the node with a request to your integration, name it
login, set the URL to your endpoint and link together input parameters with body parameters (depending on your specification).
Do not forgot to switch
fxmode for setting values dynamically.
Set sessionnode and store received token as the user identity, again it depends how the previous endpoint returns token.
And the last step is to add the
Loginnode and connect all together. Entire flow would look like this:
The logout action is very simple, just add the Logout node, connect it and save.
You have to turn off authenticated user again - the same way as you did in the Login action.
Then add a request to your API to obtain user's profile. Set Bearer authorization and link it with the session's
identityKeywhere the JWT token is stored.
session.identityKeynow you can use in any other API requests to authorize user.
And finaly set output to your account data.
Open the app configuration from main menu and change AuthType to Custom. There are two actions to set.
- 1.The first one is Login action which allows you auto-login in editor. You can add your previously created Login action and set your testing credentials. This will automatically login when you start editor. It won't have any effect in the application.
- 2.The second one is action to get current user, here you should select GetAccount action.
Save the configuration and wait until the editor backend will be restarted. Reopen the editor and move to creation Login view.
Remeber, that every save of application configuration will cause restarting editor backend.
Check if the
maincontains OneOf switching between MainView and auth views - the Login page in our case.
Create view Login and design it as on the previous image. Add two fields for email and password and button to finish login.
Do not forgot to turn off authenticated user in View Settings.
Select button and open OnClick event, where add nodes as on the picture below. In the Call Action node choose the Login action and bind parameters to the fields, then you need to reload session and navigate to Home (or where you want to). In case of login failure you can notice user with toast message, for instace.
And that's it, you just have set up your custom auth flow authenticating users against your backend instead of Adapptio.