Skip to content

OIDC login

Sign in through your identity provider, then open a session with a normal SSH client or the WebUI. This example uses Authorization Code with PKCE and runs the session in Docker.

Prerequisites

  • A Linux Bifröst host service with access to Docker.
  • A domain pointing to Bifröst, with TCP port 443 reachable.
  • An OIDC provider and the sub claim of the user you want to allow.

1. Register the IdP client

Use these settings, substituting your own domain:

Setting Value
Client type Confidential web client with a client ID and secret
Grant Authorization Code with PKCE S256
Callback URL https://gateway.example.org/login/callback
Token authentication client_secret_basic or client_secret_post
Tokens ID token and refresh token

Enable your provider's refresh-token scope/settings. The example uses offline_access.

2. Configure Bifröst

Merge this into your host configuration. Replace the domain, ACME contact, issuer, credentials and allowed subject.

/etc/engity/bifroest/configuration.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
http:
  enabled: true
  domains: [ gateway.example.org ]
  tls:
    acme:
      enabled: true
      # Set this to true means you accept the terms of:
      # https://letsencrypt.org/repository/
      acceptTerms: true
      email: operator@example.org

flows:
  - name: oidc-shell
    discoverAsSlug: Shell
    http:
      requestUser: false
    requirement:
      http:
        includedSlug: '^Shell$'
    authorization:
      type: oidcAuthorizationCode
      issuer: https://idp.example.org/realms/company
      clientId: YOUR_CLIENT_ID
      clientSecret: YOUR_CLIENT_SECRET
      scopes: [ openid, profile, offline_access ]
    environment:
      type: docker
      image: alpine
      user: "1000:1000"

      # Allows users with the field `shell` is equal to `true`
      # in their ID Token returned by the IdP to login.
      loginAllowed: '{{ eq .authorization.idToken.shell "true" }}'

(Re)start your Bifröst instance to active this configuration.

3. Sign in

Via SSH

1
ssh gateway.example.org 'id -u'
  1. Open the login link shown by your SSH client.
  2. Sign in at your IdP.
  3. Select your SSH client's two-character code from the browser's three choices to approve your own connection. A wrong choice or decline aborts the login.

The command should print 1000. Never approve a login link sent by someone else.

Via WebUI

  1. Open https://gateway.example.org/#Shell and choose OIDC.
  2. Sign in at your IdP in the automatically opened tab. If popups are blocked, use the displayed login link.
  3. The login tab closes automatically when possible. Return to the original tab to use the terminal; WebUI login has no SSH code selection.

Keep the original tab open; reloading it loses the pending login.

Alternatives

Need Change
SSH only, with browser approval Keep global HTTPS enabled; set the flow's http.enabled to false. / then returns 404 if no HTTP-enabled flow remains.
SSH without Bifröst HTTPS Enable Device Authorization at the IdP and use type: oidcDeviceAuth. Follow the IdP's verification instructions instead of the Bifröst approval step.
Saved access Configure rememberMe. Session and refresh checks still apply.

Troubleshooting

Problem Check
Callback fails Registered callback URL, selected HTTP domain, port and TLS certificate
No refresh token IdP client settings and required scopes
IdP login succeeds, access denied Allowed sub and the environment's loginAllowed rule

Next steps