website/integrations/development/forgejo/index.md
Forgejo is a lightweight, self‑hosted alternative to GitHub/GitLab, with a strong emphasis on community governance and open development.
The following placeholders are used in this guide:
authentik.company is the FQDN of the authentik installation.forgejo.company is the FQDN of the Forgejo installation.:::info This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application. :::
To support the integration of Forgejo with authentik, you need to create an application/provider pair in authentik.
Log in to authentik as an administrator and open the authentik Admin interface.
Navigate to Applications > Applications and click Create with Provider to create an application and provider pair. (Alternatively you can first create a provider separately, then create the application and connect it with the provider.)
Strict redirect URI to https://<forgejo.company>/user/oauth2/authentik/callback.Click Submit to save the new application and provider.
Log in to Forgejo as an administrator, then click on your profile icon at the top right and select Site Administration.
Select the Authentication Sources tab and then click on Add Authentication Source.
Set the following required configurations:
authentik (This must match the name used in the Redirect URI in the previous section)OpenID Connecthttps://authentik.company/static/dist/assets/icons/icon.pnghttps://authentik.company/application/o/<application_slug>/.well-known/openid-configurationemail profileClick Add Authentication Source.
Optionally, groups and property mappings can be created to manage user permissions in Forgejo.
The following groups will be created:
gituser: normal Forgejo users.gitadmin: Forgejo users with administrative permissions.gitrestricted: restricted Forgejo users.:::info Group membership is required
Users who are not part of any defined group will be denied login access. In contrast, members of the gitadmin group will have full administrative privileges, while those in the gitrestricted group will have limited access.
:::
gituser and click Create.gitadmin and gitrestricted.Log in to authentik as an administrator and open the authentik Admin interface.
Navigate to Customization > Property Mappings and click Create. Create a Scope Mapping with the following configurations:
authentik forgejo OAuth Mapping: OpenID 'forgejo')forgejoforgejo_claims = {}
if request.user.groups.filter(name="gituser").exists():
forgejo_claims["forgejo"]= "user"
if request.user.groups.filter(name="gitadmin").exists():
forgejo_claims["forgejo"]= "admin"
if request.user.groups.filter(name="gitrestricted").exists():
forgejo_claims["forgejo"]= "restricted"
return forgejo_claims
Click Finish.
Log in to authentik as an administrator and open the authentik Admin interface.
Navigate to Applications > Providers and click on the Edit icon of the Forgejo provider.
Under Advanced protocol settings > Scopes add the following scopes to Selected Scopes:
authentik default OAuth Mapping: OpenID 'email'authentik default OAuth Mapping: OpenID 'profile'authentik default OAuth Mapping: OpenID 'openid'authentik forgejo OAuth Mapping: OpenID 'forgejo'Click Update.
:::info
For this to function, the Forgejo ENABLE_AUTO_REGISTRATION: true variable must be set. More information on configurations variables in the Forgejo Configuration Cheat Sheet.
:::
email profile forgejoforgejoforgejoadminrestrictedTo verify that authentik is correctly set up with Forgejo, log out and then log back in using the Sign in with authentik button. You should be redirected to authentik, and once authenticated, you should then be signed in to Forgejo.