docs/content/integration/openid-connect/clients/forgejo/index.md
{{% oidc-common %}}
This example makes the following assumptions:
https://forgejo.{{< sitevar name="domain" nojs="example.com" >}}/https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/forgejoinsecure_secretauthelia:
https://forgejo.{{< sitevar name="domain" nojs="example.com" >}}/user/oauth2/<Authentication Name>/callback.
This means if you change this value you need to update the redirect URI.Some of the values presented in this guide can automatically be replaced with documentation variables.
{{< sitevar-preferences >}}
The following YAML configuration is an example Authelia client configuration for use with Forgejo which will operate with the application example:
identity_providers:
oidc:
## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
## See: https://www.authelia.com/c/oidc
clients:
- client_id: 'forgejo'
client_name: 'Forgejo'
client_secret: '$pbkdf2-sha512$310000$c8p78n7pUMln0jzvd4aK4Q$JNRBzwAo0ek5qKn50cFzzvE9RXV88h1wJn5KGiHrD0YKtZaR/nCb2CJPOsKaPK0hjf.9yHxzQGZziziccp6Yng' # The digest of 'insecure_secret'.
public: false
authorization_policy: 'two_factor'
require_pkce: true
pkce_challenge_method: 'S256'
redirect_uris:
- 'https://forgejo.{{< sitevar name="domain" nojs="example.com" >}}/user/oauth2/authelia/callback'
scopes:
- 'openid'
- 'email'
- 'profile'
- 'groups'
response_types:
- 'code'
grant_types:
- 'authorization_code'
access_token_signed_response_alg: 'none'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_basic'
To configure Forgejo there are two methods, using the Web GUI, or using the CLI.
To configure Forgejo to utilize Authelia as an OpenID Connect 1.0 Provider, use the following instructions:
autheliaOpenID Connectforgejoinsecure_secrethttps://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/.well-known/openid-configurationemail profile groups{{< figure src="forgejo.png" alt="Forgejo" width="300" >}}
Important Note: Please refer to the Forgejo CLI Guide regarding the correct usage of the CLI.
To configure Forgejo to utilize Authelia as an OpenID Connect 1.0 Provider, use the following instructions:
forgejo migrate.forgejo admin auth add-oauth --provider=openidConnect --name=authelia --key=forgejo --secret=insecure_secret --auto-discover-url=https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/.well-known/openid-configuration --scopes='openid email profile groups'To configure Forgejo to perform automatic user creation for the {{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}} domain via OpenID Connect 1.0:
app.ini:[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = true
WHITELISTED_URIS = {{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}
[service]
DISABLE_REGISTRATION = false
ALLOW_ONLY_EXTERNAL_REGISTRATION = true
SHOW_REGISTRATION_BUTTON = false
To configure Forgejo to sync ssh public keys from Authelia you can define sshpubkey as a multi-valued Extra Attribute and combine the following configuration with the configuration.yml above.
identity_providers:
oidc:
claims_policies:
forgejo:
custom_claims:
sshpubkey: {}
scopes:
forgejo:
claims:
- sshpubkey
clients:
- client_id: 'forgejo'
claims_policy: 'forgejo'
scopes:
- 'forgejo'
Forgejo configuration largely follows the instructions from Web GUI and CLI
Follow the instructions in Web GUI with the following additions
email profile groups forgejosshpubkey{{< figure src="forgejo-sshpubkey.png" alt="Forgejo" width="300" >}}
Follow the instructions from CLI, and change the following command:
forgejo admin auth add-oauth --auto-discover-url=https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/.well-known/openid-configuration --name=authelia --provider=openidConnect --key=forgejo --secret=insecure_secret --scopes='openid email profile groups forgejo' --attribute-ssh-public-key=sshpubkey