Enabling Authentication
To enable authentication and automatically create login and signup APIs in your project, follow the steps below. You will configure the authentication settings via a set of options, checkboxes, and fields within the system.
Steps to Enable Authentication
1. Open the Auth Tab
- First, navigate to the Auth tab in the settings of your project. This is where you can configure the authentication settings.
2. Enable API Security
- Check the box labeled Enable API Security. This will apply the necessary security key to your API, ensuring that all authentication requests are securely handled.
Security Key Configuration:
- Auto-generate the Security Key: The system can automatically generate a security key for you, which is recommended for most use cases.
- Manual Entry: Alternatively, you can manually enter the security key if you have specific security requirements or if you are using a pre-generated key.
3. Configure the Identity and Password Fields
The Identity and Password fields are the core components of user authentication. These fields will store and validate the login credentials.
Steps to configure these fields:
- Select Data Store: Choose the data store where your user authentication data will be stored. Common options include databases like MongoDB, SQL databases, etc.
- Select Data Model: Select the data model that corresponds to your user information schema. Ensure that this model includes fields for Identity (usually a username or email) and Password.
4. Enable Login and Signup Configuration
To enable automatic generation of login and signup APIs, enable the Login and Signup Configuration options. These checkboxes will add pre and post scripts to the authentication APIs, allowing you to customize the behavior of the login and signup processes.
- Pre-Script: A script that runs before the authentication process starts. You can use this to perform checks or modify data before the user is authenticated.
- Post-Script: A script that runs after the authentication process completes. You can use this to perform actions like sending welcome emails or updating logs after a user has successfully logged in or signed up.
5. Save Changes
Once you have configured the authentication settings, click Save to update the system. This will apply all your configuration choices and automatically generate the login and signup APIs.
Checkboxes Explained
Enable API Security
- Function: Enables the security features for the authentication process.
- Default: Disabled (unchecked).
- Recommendation: Always enable to ensure secure API handling.
Enable Login and Signup Configuration
- Function: Adds configuration options for login and signup APIs, including pre and post scripts.
- Default: Disabled (unchecked).
- Recommendation: Enable if you want to customize the login and signup processes.
Pre-Script & Post-Script
- Function: Allows you to add custom logic to the login and signup process at specified points (before or after the user is authenticated).
- Default: Disabled (unchecked).
- Recommendation: Enable if you need custom behavior (e.g., logging, email notifications).
Final Notes
By following these steps and configuring the appropriate fields, you can quickly enable authentication in your project and have your login and signup APIs automatically generated. Ensure you review the settings and customize the pre and post scripts as needed to fit your project’s security and user flow requirements.