REST API User Details Service Worksheet
This worksheet defines where and how user details should be retrieved.
Basic Settings
Enable user detail service
Yes, enable REST API User Details Service. No, does not enable REST API User Details Service.
Source
It defines how user details should be retrieved.
- Database - choose this to load user details from a database. This is the only option available in the current version. There will be more options that will be supported in the future.
Database User Management
Data Source
If your REST API uses the default data source, put primary here. If it uses another data source ID or you want to use a different data source ID, you need to configure the data source in the Data Source Configuration section of the REST API Worksheet then input the Identifier name here. Note that the Identifier name must be lowercase and cannot be primary as it has been used by the REST API itself already.
User state SQL query
This field should contain the SQL statement that retrieves user details of the logged-in user from the database. It must return one row with one column called "USER_STATE" which is an integer that represents the state of the logged-in user:
0 - The account is normal. Security authentication will return login successful if the user name and password matches.
1 - The account has expired. Authentication will fail.
2 - The account is locked. Authentication will fail.
If your API does not support user state, use a SQL statement that always returns 0.
SELECT 0 AS USER_STATE FROM DUAL
Use ":USERNAME" in the SQL statement to indicate the current logged in user. AlchemyJ will replace it with the actual user ID of the logged-in user.
SELECT USER_STATE FROM SYS_USER WHERE NAME = :USERNAME
Authority SQL query
This field should contain the SQL statement that retrieves an authority list of the logged-in user from the database. It must return a list of records with a column called "AUTHORITY" which represents the authority ID.
Use ":USERNAME" in the SQL statement to indicate the current logged in user. AlchemyJ will replace it with the actual user ID of the logged-in user.
SELECT AUTHORITY FROM SYS_AUTHORITY WHERE NAME = :USERNAME
If your API does not distinguish users with different authorities, use a SQL statement that always returns a fixed value like the following one below:
SELECT 'ADMIN' AS AUTHORITY FROM DUAL