Authentication
The Writer Framework authentication module allows you to restrict access to your application. Framework will be able to authenticate a user through an identity provider such as Google, Microsoft, Facebook, Github, Auth0, etc.
Authentication is done before accessing the application. It is not possible to trigger authentication for certain pages exclusively.
Static assets from Writer Framework exposed through /static
and /extensions
endpoints are not protected behind Authentication.
Use Basic Auth
Basic Auth is a simple authentication method that uses a username and password. Authentication configuration is done in the server_setup.py module.
Password authentication and Basic Auth are not sufficiently secure for critical applications. If HTTPS encryption fails, a user could potentially intercept passwords in plaintext. Additionally, these methods are vulnerable to brute force attacks that attempt to crack passwords. To enhance security, it is advisable to implement authentication through trusted identity providers such as Google, Microsoft, Facebook, GitHub, or Auth0.
Brute force protection
A simple brute force protection is implemented by default. If a user fails to log in, the IP of this user is blocked.
Writer framework will ban the IP from either the X-Forwarded-For
header or the X-Real-IP
header or the client IP address.
When a user fails to log in, they wait 1 second before they can try again. This time can be modified by
modifying the value of delay_after_failure
.
Use OIDC provider
Authentication configuration is done in the server_setup.py
module. The configuration depends on your identity provider.
Here is an example configuration for Google.
Use pre-configured OIDC
The Writer Framework provides pre-configured OIDC providers. You can use them directly in your application.
Provider | Function | Description |
---|---|---|
writer.auth.Google | Allow your users to login with their Google Account | |
Github | writer.auth.Github | Allow your users to login with their Github Account |
Auth0 | writer.auth.Auth0 | Allow your users to login with different providers or with login password through Auth0 |
You have to register your application into Google Cloud Console.
Github
You have to register your application into Github
Auth0
You have to register your application into Auth0.
Authentication workflow
App static assets
Static assets in your application are inaccessible. You can use the app_static_public
parameter to allow their usage.
When app_static_public
is set to True
, the static assets in your application are accessible without authentication.
User information in event handler
When the user_info
route is configured, user information will be accessible
in the event handler through the session
argument.
Unauthorize access
It is possible to reject a user who, for example, does not have the correct email address.
You can also use userinfo inside app. You can restrict access to certain pages
inside the application by using the session
object. See User information in
event handler
The default authentication error page look like this:
Parameter | Description |
---|---|
status_code | HTTP status code |
message | Error message |
more_info | Additional information |
Modify user info
User info can be modified in the callback.
Custom unauthorized page
You can customize the access denial page using your own template.
Enable in edit mode
Authentication is disabled in edit mode. To activate it, you must trigger the loading of the server_setup module in edition mode.