This plugin allows login and registration via OAuth2.
Works perfectly with a large variety of identity management solutions, like KeyCloak.
- Clone this repository to CTFd/plugins.
- Install required python packages. If you are using Docker, it is done by rebuilding the container. Instead, if you are using other hosting solutions, you can install them with the command
pip3 install -r requirements.txt
from the plugin folder (CTFd/plugins/CTFd-SSO-plugin
). - Edit the
[extra]
section ofCTFd/config.ini
adding these two values:OAUTH_ALWAYS_POSSIBLE
: setTrue
if you want to allow registration via OAuth even if normal registration is turned off. Default isFalse
.OAUTH_CREATE_BUTTONS
: setTrue
if you want to automatically add the OAuth login buttons in the login page. Default isFalse
.
- Start or restart CTFd.
- In the
Admin Panel
go toPlugins
>ctfd-sso
. There you can view and delete existing clients, or add a new one by pressing plus symbol. - Insert a client name (it will be shown on the button) and the other information according to the identity provider. Then press
Add
. - Log in :)
If you want to automatically create admin accounts via the Identity Provider, make sure that the API Endpoint returns a key roles
containing an array. The first element of that array will be set as the user role in CTFd.
For example if an user should be admin, the Identity Provider should return something like: {"preferred_username": "username", "email": "[email protected]", "roles": ["admin"]}
The allowed roles for CTFd are admin
and user
, but the latter is set by default.
If configured properly, this plugin will attempt to automatically insert the login buttons in the login page. It might fail if the theme isn't the original one. In this case or if you want to create some custom buttons, they should point to sso/login/<client_id>
.