# WG-Portal

## Tested Versions

- [Authelia]
  - [v4.39.20](https://github.com/authelia/authelia/releases/tag/v4.39.20)
- [WG-Portal]
  - [v2.3.1](https://github.com/h44z/wg-portal/releases/tag/v2.3.1)

{{% oidc-common %}}

### Assumptions

This example makes the following assumptions:

- __Application Root URL:__ `https://wg-portal.{{< sitevar name="domain" nojs="example.com" >}}/`
- __Authelia Root URL:__ `https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/`
- __Provider ID:__ `{{< sitevar name="provider-id" nojs="authelia" >}}`
- __Client ID:__ `{{< sitevar name="client-id" nojs="wg-portal" >}}`
- __Client Secret:__ `insecure_secret`

Some of the values presented in this guide can automatically be replaced with documentation variables.

{{< sitevar-preferences >}}

## Configuration

### Authelia

The following YAML configuration is an example __Authelia__ [client configuration] for use with [WG-Portal] which will
operate with the application example:

```yaml {title="configuration.yml"}
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: '{{< sitevar name="client-id" nojs="wg-portal" >}}'
        client_name: 'WG-Portal'
        client_secret: '$pbkdf2-sha512$310000$hDm3SNqIGebGH33JVGnCZA$5XA6C8mg.j2MejL1uJfHwFPEqXbW2K.xufEuIIpwN.0Jn0dKs/LLvRKbPTo7MTOjTpwoAVyZj6BsUTHeBjd3sQ'  # The digest of 'insecure_secret'.
        public: false
        authorization_policy: 'two_factor'
        require_pkce: true
        pkce_challenge_method: 'S256'
        redirect_uris:
          - 'https://wg-portal.{{< sitevar name="domain" nojs="example.com" >}}/api/v0/auth/login/{{< sitevar name="provider-id" nojs="authelia" >}}/callback'
        scopes:
          - 'openid'
          - 'email'
          - 'profile'
        response_types:
          - 'code'
        grant_types:
          - 'authorization_code'
        token_endpoint_auth_method: 'client_secret_basic'
```

### Application

To configure [WG-Portal] there is one method, using the [config.yml][WG-Portal OIDC Documentation] file.

#### Config.yml

To configure [WG-Portal] to utilize [Authelia] as an [OpenID Connect 1.0] Provider, use the following configuration:

```yaml {title="config.yml"}
auth:
  # Other authentication configurations go here
  oidc:
    - provider_name: {{< sitevar name="provider-id" nojs="authelia" >}}
      display_name: Log in with Authelia
      base_url: https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}
      client_id: {{< sitevar name="client-id" nojs="wg-portal" >}}
      client_secret: insecure_secret
      extra_scopes: 
        - email
        - profile
      field_map:
        user_identifier: preferred_username
        email: email
        firstname: given_name
        lastname: family_name
```

Mapping users to admins by group did not work at the time of writing this.

## See Also

- [WG-Portal OIDC Documentation]

[Authelia]: https://www.authelia.com
[WG-Portal]: https://wgportal.org
[WG-Portal OIDC Documentation]: https://wgportal.org/master/documentation/configuration/overview/#oidc
[OpenID Connect 1.0]: ../../introduction.md
[client configuration]: ../../../../configuration/identity-providers/openid-connect/clients.md
