add Auto Sign Up feature
Created by: deepakduggirala
Description
The Auto Sign Up feature allows new users to be automatically created when they attempt to log in with an authentication provider. This feature simplifies the user onboarding process but comes with potential security risks, It is suitable for demo purposes. This feature can disabled though config (api/config/default.json).
"auto_sign_up": {
"enabled": false,
"default_role": "user"
}
The role for the created users can be configured using auto_sign_up.default_role
. Care must be taken when setting this value to operator or admin to make sure this is only done with demo instances and trusted audience. Added a warning log when auto sign up is enabled, indicating the default role and potential security risks.
Workflow
The auto sign-up process follows these steps:
-
Find user by attribute key and value
- The system attempts to locate an existing user using a specified attribute key (e.g., email, username) and value provided by the authentication provider.
-
If a user is found:
- If the user is active, return the user object.
- If the user is not active, return
null
.
-
If no user is found:
- If auto sign-up is enabled:
- Create a new user using the data provided by the authentication provider.
- If the inferred username conflicts with an existing username, append a random string to resolve the conflict.
- Return the newly created user object.
- If auto sign-up is not enabled:
- Return
null
.
- Return
- If auto sign-up is enabled:
Examples
Example 1: Existing Active User
- User logs in with OAuth provider using
email = user@example.com
. - The system finds an active user with this email.
- The user is authenticated and logged in successfully.
Example 2: Existing Inactive User
- User logs in with OAuth provider using
email = user@example.com
. - The system finds a user with this email, but the user is inactive.
- The system returns
null
→ User cannot log in.
Example 3: New User with Auto Sign-Up Enabled
- User logs in with OAuth provider using
email = newuser@example.com
. - The system does not find an existing user.
- Auto sign-up is enabled:
- A new user is created with the provided email.
- If the inferred username conflicts, a random string is appended.
- The new user is authenticated and logged in.
Example 4: New User with Auto Sign-Up Disabled
- User logs in with OAuth provider using
email = newuser@example.com
. - The system does not find an existing user.
- Auto sign-up is disabled:
- The system returns
null
→ User cannot log in.
- The system returns
Changes Made
List the main changes made in this PR. Be as specific as possible.
-
Feature added -
Bug fixed -
Code refactored -
Tests changed -
Documentation updated -
Other changes: [describe]
Checklist
Before submitting this PR, please make sure that:
-
Your code passes linting and coding style checks. -
Documentation has been updated to reflect the changes. -
You have reviewed your own code and resolved any merge conflicts. -
You have requested a review from at least one team member. -
Any relevant issue(s) have been linked to this PR.