Skip to content

Single sign-on

Sign in to Avenvail with Pocket ID, Authentik, Authelia, Keycloak or another OpenID Connect provider.

Avenvail can sign people in with one OpenID Connect (OIDC) provider, such as Pocket ID, Authentik, Authelia or Keycloak. Passwords keep working alongside it unless you turn them off.

Avenvail uses the authorization code flow with PKCE, and asks for openid profile email by default. An Avenvail account is linked to the provider's issuer and its stable user id (the sub claim). It is never matched by email address or user name, so renaming someone at the provider doesn't change which Avenvail account they get.

Set up the provider

Create an OIDC client (some providers call it an application) with:

SettingValue
Redirect URI (callback URL)<your Avenvail address>/api/v1/auth/sso/callback, for example https://files.example.com/api/v1/auth/sso/callback
Client typeConfidential, with a client secret. Public clients without a secret also work.
Client authenticationClient secret in the request body (client_secret_post)
Grant typeAuthorization code
Scopesopenid, profile, email, plus groups if you use allowed groups

Then add the provider to Avenvail's .env and restart with docker compose up -d:

Avenvail__Oidc__Authority=https://id.example.com
Avenvail__Oidc__ClientId=avenvail
Avenvail__Oidc__ClientSecret=<client secret>
Avenvail__Oidc__DisplayName=Pocket ID

The sign-in page now shows Sign in with Pocket ID above the password form.

Provider notes

ProviderAuthorityNotes
Pocket IDhttps://id.example.comAdd the callback URL to the client. Pocket ID sends groups when Avenvail asks for the groups scope.
Authentikhttps://authentik.example.com/application/o/<application slug>/Create an OAuth2/OpenID provider and an application for it. Use the issuer shown on the provider page, including the trailing slash.
Autheliahttps://auth.example.comIn the client's configuration, set token_endpoint_auth_method: 'client_secret_post' and list the scopes Avenvail asks for.
Keycloakhttps://keycloak.example.com/realms/<realm>Create an OpenID Connect client with client authentication on. To send groups, add a Group Membership mapper with the token claim name groups.

Settings

SettingDefaultMeaning
Avenvail__Oidc__AuthorityThe provider's issuer URL. Setting it turns single sign-on on. Must be https when your base URL is.
Avenvail__Oidc__ClientIdClient id from the provider. Required with the authority.
Avenvail__Oidc__ClientSecretClient secret. Leave it empty for a public client.
Avenvail__Oidc__ClientSecretFileOr a path to a file holding it, e.g. a Docker secret. Set at most one.
Avenvail__Oidc__DisplayNameSSOName on the sign-in button: "Sign in with DisplayName".
Avenvail__Oidc__Scopesopenid profile emailScopes to ask for, separated by spaces or commas. Must include openid.
Avenvail__Oidc__AutoCreateUsersfalseCreates a Member account the first time someone signs in who isn't linked yet.
Avenvail__Oidc__AllowedGroupsGroups allowed to sign in with single sign-on, separated by spaces or commas. Empty allows everyone the provider lets through.
Avenvail__Oidc__GroupsClaimgroupsClaim that lists the user's groups.
Avenvail__Oidc__DisablePasswordLoginfalseHides the password form and refuses password sign-in.

Who can sign in

Someone signing in with single sign-on for the first time needs an Avenvail account linked to their identity. There are three ways to get one:

  • Link an existing account. Sign in with your password, open Settings › Sign-in and security, and choose Link. You're sent to the provider and back. From then on either way signs you in.
  • Finish an invite with single sign-on. When an administrator adds a user, the setup link offers Continue with the provider as well as choosing a password.
  • Create accounts automatically. With Avenvail__Oidc__AutoCreateUsers=true, anyone who isn't linked yet gets a new Member account when they first sign in. The user name comes from the provider's preferred_username, then name, then the part of the email before @. If it's taken, Avenvail adds -2, -3 and so on.

Without auto-create, an identity that isn't linked is turned away with a message to sign in with a password and link it, or to ask for an invite. Roles are always managed in Avenvail: promote someone in Settings › Users.

The administrator created during first-run setup always starts with a password. Link single sign-on to it afterwards.

Limit who can sign in

Avenvail__Oidc__AllowedGroups checks every single sign-on, not only the first one. Someone removed from all the allowed groups can't sign in with single sign-on anymore, though their password still works if they have one. Add the provider's groups scope to Avenvail__Oidc__Scopes, for example openid profile email groups, so the provider sends the groups.

Most providers can also restrict which users may use a client. Doing it there works too, and keeps the decision in one place.

Turning off passwords

With Avenvail__Oidc__DisablePasswordLogin=true, the sign-in page shows only the single sign-on button, setup links can only be finished with single sign-on, and nobody can change or set a password.

If the provider is down, nobody can sign in. To get back in, remove the setting and restart: passwords work again for every account that has one. If your own account has no password, run admin reset-password (see Troubleshooting) first.

Unlinking and resetting

Settings › Sign-in and security shows whether your account is linked. Link a different account replaces the link. Unlink removes it, but only once you have a password, so you can still sign in. An account created by single sign-on can set a password on the same page.

When an administrator resets someone's password in Settings › Users, the single sign-on link is removed too, and the new setup link lets them link it again. Users with a link show an SSO badge in the list.

Two-factor authentication

Signing in with single sign-on never asks for Avenvail's two-factor codes. Your identity provider decides which factors to ask for, so turn them on there.

API tokens and ShareX

API tokens, including the one ShareX uses, are separate from how you sign in. Linking, unlinking or turning off passwords doesn't affect them. Tokens are still created from a signed-in browser session, whichever way you signed in.

Troubleshooting

MessageWhat to check
Single sign-on didn't completeThe server log has the reason. Usually the redirect URI at the provider doesn't match Avenvail__BaseUrl exactly, the client secret is wrong, or Avenvail can't reach the provider's address from inside the container.
That account isn't linked to Avenvail yetLink it from your account, finish an invite with it, or turn on auto-create.
That single sign-on account is already linked to another Avenvail userOne identity can be linked to only one Avenvail account. Unlink it from the other account first.
Your single sign-on account isn't in a group allowed to use AvenvailCheck Avenvail__Oidc__AllowedGroups, and that the provider sends groups in the claim named by Avenvail__Oidc__GroupsClaim.

Avenvail reads the provider's discovery document when someone first signs in after a restart. If you change the provider, existing links stop matching, because they belong to the old issuer: link each account again.