Search
K

Custom Auth

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. 1.
    Create integration to your authority backend
  2. 2.
    Add actions for login, logout and getting current user profile
  3. 3.
    Change Auth type in App Configuration
  4. 4.
    Setup login page

Integration

Add integration to your authority backend, it will be a REST API or a GraphQL in most cases.

Actions

Login

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 fx mode for setting values dynamically.
Next add Set session node 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 Login node and connect all together. Entire flow would look like this:

Logout

The logout action is very simple, just add the Logout node, connect it and save.

GetAccount

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 identityKey where the JWT token is stored.
session.identityKey now you can use in any other API requests to authorize user.
And finaly set output to your account data.

Change Auth type to Custom

Open the app configuration from main menu and change AuthType to Custom. There are two actions to set.
  1. 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. 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.

Views

Check if the main contains OneOf switching between MainView and auth views - the Login page in our case.

Login

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.