Users & Authentication
- Updating your
- Updating your session-manager
- Deploying your changes
This guide explains how to add users and basic password authentication to your Alan application. The guide assumes familiarity with the Alan project structure from the online Alan IDE.
For enabling application users and authentication, the following steps are required:
- updating your
- updating the
- deploying your app with an initial username and password for bootstrapping authentication
Read the section on Application users from the application language docs.
From the example model that you find there, copy the parts that you need for a
'Passwords' collection, and copy the contents of the
For basic password authentication, you can ignore the parts about authorities.
Build your app, and fix any errors that you get.
Note that if you removed
anonymous from the
users section, the compiler will complain about your client settings (
Fix the error by setting
anonymous login: to
disabled, as your app no longer supports
Updating your session-manager
An Alan session-manager is responsible for showing the login page, handling authentication, and storing and revoking user sessions.
Open the file
systems/sessions/config.alan and set
config.alan file, you can also enable user creation for supporting user sign-up via the login page.
For user sign-up, make sure that you have the required
user-initializer: section in your
Deploying your changes
You can now run Alan: Deploy with the ‘empty’ option. *
After a succesfull deployment, open your app and sign in with these credentials:
When asked, choose your own password for the
You have now succesfully bootstrapped authentication.
You can add
Users in your app, and send them urls for signing in.
* If you wish to use your own
migration.alan file, follow these steps:
- Run the command
Alan: Generate Migrationfrom VS Code, hit Enter twice, and select ‘initialization from empty dataset’ as the ‘migration type’.
- The generated file
migrations/from_empty/migration.alanwill provide you with initial username/password data for bootstrapping authentication. Copy the parts for the
Passwordscollection to your own
migration.alanfile. Do not change the username (or password hash) in your migration file!