Extensions
Since the Goal of EZAuth is to be as extensive as possible, it is possible to create your own extensions to add functionality to EZAuth.
Preparation¶
To allow Extensions, you need to create a new folder called extensions/
in the directory specified in the docker-compose file (default ./
root of Repository), if it doesn't already exist. This folder is not tracked by git, so you can safely add your own extensions without the risk of losing them when updating the repository.
EZAuth Developer Mode
To also enjoy a greater developement experience, you can start EZAuth in Development Mode. This will allow you to see changes in your extensions without restarting the server. It will also show you more detailed error messages, which can be helpful when developing extensions.
Creating an Extension¶
Extensions can break EVERYTHING (including all your userdata)
Since Extensions are a really advanced feature, they are not recommended to be developed by beginners. However, if you are an experienced developer, you can create your own extensions.
-
New Folder for the Extension
Inside the
extensions/
directory, create a new folder for your extension. The name of the folder should be the name of your extension. We force a folder, to make it easier for you to structure your extension and keep an overview of all the installed extensions. We use the namemy_extension
for this example. -
Make the Extension Loadable
To make EZAuth recognize your extension as a valid one, add a
__init__.py
file to your newly created extension folder. This file must be there and export arouter
which is a FastAPI Router.Depending on the structure of your Extension, you can either write the whole extension into the
__init__.py
file or import only the router from another file.Imports in Extension Files
Be careful when doing imports in extensions, as by just importing other files using
.myextension
won't work (importlib can't find the module). You have to use the full import path to the file starting withextensions.my_extension.
-> E.g.extensions.my_extension.myextension
-
Provide some information about the Extension
To make it easier for users to understand what your extension does, you can provide a
README.md
file in your extension folder. This file can contain information about the extension, how to use it, and what it does.This is especially useful if you want to share your extension with others.
Downloading Extensions¶
If you want to use an extension that someone else has created, you can download it from a repository and place it in the extensions/
directory. The extension should be structured as described above.
Extension Repository
If you want to share your extension with others, you can create a repository on GitHub or any other platform and share the link with others. This way, others can easily download your extension and use it in their EZAuth instance. If you want to share your extension with the community, you can also create a Pull Request to add your extension to the official EZAuth Extension Repository.