Skip to content

Commit

Permalink
Add authentication docs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Jan 9, 2024
1 parent a8f1ef3 commit 6e6bc4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/authentication.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _authentication:

=========================
Setting up Authentication
=========================

Locust uses `Flask-Login <https://pypi.org/project/Flask-Login/>`_ to handle authentication. The ``login_manager`` is exposed on ``environment.web_ui.app``, allowing the flexibility for you to implement any kind of auth that you would like!

To use username / password authentication, simply provide a ``usernamePasswordCallback`` to the ``environment.web_ui.auth_args``. You are responsible for defining the route for the callback and implementing the authentication.

Authentication providers can additionally be configured to allow authentication from 3rd parties such as GitHub or an SSO. Simply provider a list of desired ``auth_providers``. You may specify the ``label`` and ``icon`` for display on the button. The ``callback_url`` will be the url that the button directs to. You will be responsible for defining the callback route as well as the authentication with the 3rd party.

Whether you are using username / password authentication, an auth provider, or both, a ``user_loader`` needs to be proivded to the ``login_manager``. The ``user_loader`` should return ``None`` to deny authentication and return a User object when authentication to the app should be granted.

A full example can be seen `in the auth example <https://github.com/locustio/locust/tree/master/examples/auth.py>`_.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Other functionalities
extending-locust
logging
use-as-lib
authentication
Further reading / knowledgebase
Expand Down

0 comments on commit 6e6bc4e

Please sign in to comment.