website/integrations/development/gitea/index.md
Gitea is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.
The following placeholders are used in this guide:
authentik.company is the FQDN of the authentik installation.gitea.company is the FQDN of the Gitea 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 Gitea with authentik, you need to create an application/provider pair in authentik.
Strict redirect URI to https://<gitea.company>/user/oauth2/authentik/callback.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 profile:::info This step is optional and shows how to set claims to control the permissions of users in Gitea by adding them to groups. :::
The following groups will be created:
gituser: normal Gitea users.gitadmin: Gitea users with administrative permissions.gitrestricted: restricted Gitea users.:::info Users who are in none of these groups will not be able to log in to Gitea. :::
gituser and click Create.gitadmin and gitrestricted.:::info You can add users to the groups at any point. :::
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 gitea OAuth Mapping: OpenID 'gitea')giteagitea_claims = {}
if request.user.groups.filter(name="gituser").exists():
gitea_claims["gitea"]= "user"
if request.user.groups.filter(name="gitadmin").exists():
gitea_claims["gitea"]= "admin"
if request.user.groups.filter(name="gitrestricted").exists():
gitea_claims["gitea"]= "restricted"
return gitea_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 Gitea 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 gitea OAuth Mapping: OpenID 'gitea'Click Update.
:::info
For this to function, the Gitea ENABLE_AUTO_REGISTRATION: true variable must be set. More information on configurations variables in the Gitea Configuration Cheat Sheet.
:::
email profile giteagiteagiteaadminrestricted:::info
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.
:::
authentik authentication can be configured automatically in Kubernetes deployments using its Helm chart.
Add the following to your Gitea Helm chart values.yaml file:
gitea:
oauth:
- name: "authentik"
provider: "openidConnect"
key: "<Client ID from authentik>"
secret: "<Client secret from authentik>"
autoDiscoverUrl: "https://authentik.company/application/o/<application_slug>/.well-known/openid-configuration"
iconUrl: "https://authentik.company/static/dist/assets/icons/icon.png"
scopes: "email profile"
You can also utilize a Kubernetes Secret object to store and manage the sensitive key and secret values.
apiVersion: v1
kind: Secret
metadata:
name: gitea-authentik-secret
type: Opaque
stringData:
key: "<Client ID from authentik>"
secret: "<Client secret from authentik>"
values.yaml file:gitea:
oauth:
- name: "authentik"
provider: "openidConnect"
existingSecret: gitea-authentik-secret
autoDiscoverUrl: "https://authentik.company/application/o/<application_slug>/.well-known/openid-configuration"
iconUrl: "https://authentik.company/static/dist/assets/icons/icon.png"
scopes: "email profile"
To verify that authentik is correctly set up with Gitea, log out and then log back in using the Sign in with authentik button.