Tinyauth Authentication
Tinyauth is a self-hosted service that signs people in for the applications behind a reverse proxy. FileRun has two plugins for it, which sign the users of Tinyauth in to FileRun without a second password:
Tinyauth OpenID Connect: FileRun uses Tinyauth as an OpenID Connect provider. The sign-in button sends the person to Tinyauth, and Tinyauth sends the person back. This plugin needs Tinyauth5.1.0or newer, and it can import the groups that Tinyauth sends.Tinyauth Forward Auth: the proxy in front of FileRun asks Tinyauth about each request, and adds the person to the request. FileRun signs in the person whom Tinyauth has already signed in.
This page describes both plugins. FileRun connects to Tinyauth through an authentication source. You
add the source in the control panel, under Security → Authentication. For the settings that
every source has, such as Role of new user accounts, see
Authentication integration.
Tinyauth OpenID Connect
Step 1: Register FileRun in Tinyauth
Under Authentication sources, click Add, and select Tinyauth OpenID Connect in the Plugin
list. The Tinyauth OpenID Connect plugin options show what to do in Tinyauth:
-
Make a client ID and a client secret with this command:
1docker run --rm ghcr.io/tinyauthapp/tinyauth:v5 oidc create files -
Copy the lines that the window shows into the environment of Tinyauth. Put the client ID and the client secret of the command in place of
{client ID}and{client secret}. The last line holds the redirect URL of your FileRun installation, which the window fills in.1TINYAUTH_OIDC_CLIENTS_FILES_CLIENTID={client ID} 2TINYAUTH_OIDC_CLIENTS_FILES_CLIENTSECRET={client secret} 3TINYAUTH_OIDC_CLIENTS_FILES_NAME=Files 4TINYAUTH_OIDC_CLIENTS_FILES_TRUSTEDREDIRECTURIS={redirect URL} -
Restart Tinyauth.
Step 2: Fill in the source
Issuer URL: required. The address of your Tinyauth server, such ashttps://auth.example.com. FileRun reads the configuration of the provider from this address.Client IDandClient Secret: required. The values of the command of step 1.Groups to import: optional. The names of the groups of Tinyauth that FileRun creates and gives to the users. Separate several names with commas. A group that is not on the list is not imported. See The group sync.
There is nothing else to set. Tinyauth sends the standard OpenID Connect claims, so the scopes and
the field mapping are built into the plugin. FileRun also asks Tinyauth for the scope groups,
without which Tinyauth sends no groups.
Choose the Role of new user accounts, and click Save.
Step 3: Test the source
Save the source with the Enabled checkbox selected, because the test link works only while the
source is enabled. Then select the source in the list of sources and click Test. FileRun reads the
configuration of Tinyauth and its token signing keys, and the test window shows a link that starts
a sign-in. Open the link in a private browser window.
The account
At the first sign-in of a Tinyauth user, FileRun creates the user account:
- The username is the
preferred_usernamethat Tinyauth sends. - The first name and the last name are the
given_nameand thefamily_name. Tinyauth sends them only for a local user that has them in the configuration of Tinyauth. For the other users, the first name is the full name, and the last name stays empty. - The e-mail address is the
emailthat Tinyauth sends. - The account is linked to the ID of the user at Tinyauth.
Tinyauth makes the ID of a user from the username and the client ID. So two users with the same username in different sign-in methods of Tinyauth, such as a local user and a GitHub user, sign in to the same FileRun account. A new username in Tinyauth is a new ID, which is not linked to the account. The rules of the links are described in Linked accounts.
Tinyauth Forward Auth
How the sign-in works
- A person opens FileRun through the proxy. The proxy asks Tinyauth about the request. When the person is not signed in to Tinyauth yet, Tinyauth shows its own sign-in page first.
- The proxy forwards the request to FileRun, and adds the person to the request, in these headers:
Remote-User: the usernameRemote-Email: the e-mail addressRemote-Name: the full name
- The person clicks the sign-in button of the source. FileRun reads the headers and signs the person in, with no other step.
The headers have no signature. The proxy removes these headers from the request of the browser only
when its configuration lists them. FileRun trusts the headers only in the requests that come from
the Trusted addresses of the source. See Security.
FileRun reads no other header of Tinyauth, such as Remote-Groups. This plugin does not import the
groups of Tinyauth.
Step 1: Configure the proxy
The proxy must list the headers Remote-User, Remote-Email and Remote-Name in its
configuration. The window of the source shows these examples, for Traefik, Caddy and nginx:
1# Traefik: the labels of the middleware
2traefik.http.middlewares.tinyauth.forwardauth.address=http://tinyauth:3000/api/auth/traefik
3traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders=Remote-User,Remote-Email,Remote-Name
4
5# Caddy 2.11.4 or newer
6forward_auth tinyauth:3000 {
7 uri /api/auth/caddy
8 copy_headers Remote-User Remote-Email Remote-Name
9}
10
11# nginx: in the location of this server, after "auth_request"
12auth_request_set $tinyauth_user $upstream_http_remote_user;
13auth_request_set $tinyauth_email $upstream_http_remote_email;
14auth_request_set $tinyauth_name $upstream_http_remote_name;
15proxy_set_header Remote-User $tinyauth_user;
16proxy_set_header Remote-Email $tinyauth_email;
17proxy_set_header Remote-Name $tinyauth_name;
Warning
Without this configuration, any user can sign in as another user. Check these points:
- The default example of Tinyauth for Traefik lists no headers. Add the line
authResponseHeadersof the example above.- Caddy needs version
2.11.4or newer.- The web server of FileRun must drop the headers whose names contain an underscore, such as
Remote_User. Apache and nginx do this by default.
Step 2: Find the trusted address
The trusted address is the IP address from which the proxy connects to FileRun, as the server of FileRun sees it. When you do not know the address, the test of the source shows it. Add the source in step 3 with any address, open FileRun through the proxy, and run the test. See Step 4.
Step 3: Add the source in FileRun
Under Authentication sources, click Add, and select Tinyauth Forward Auth in the Plugin
list. Then fill in the Tinyauth Forward Auth plugin options:
App URL: required. The address of Tinyauth, which is the value ofTINYAUTH_APPURLin its configuration. The user accounts of FileRun are linked to the users of this Tinyauth server.Trusted addresses: required. The addresses from which the proxy connects to FileRun. Separate several addresses with commas. Each entry can have one of these forms:- one address, such as
172.18.0.5orfd00::5 - CIDR, such as
172.18.0.0/16orfd00::/64 - a range, such as
172.18.0.2-172.18.0.20 - a wildcard, for IPv4 only, such as
172.18.0.*
- one address, such as
Choose the Role of new user accounts, and click Save.
When the App URL changes later, the accounts stay linked to the old address. Check
Move the N linked user accounts along if the issuer URL changes when you save the new address. See
When the provider moves to a new address.
Step 4: Test the source
Open FileRun through the proxy, and sign in as the superuser. Save the source with the Enabled
checkbox selected, select it in the list of sources, and click Test. The request of the test goes
through the proxy, in the same way as a sign-in. The test window shows:
- whether the request came from a trusted address. When it did not, add the address that the table
shows to the
Trusted addresses. - a table with the
Addressof the request, and the headersRemote-User,Remote-EmailandRemote-Name - whether the request contains the user. When it does not, list the three headers in the configuration of the proxy.
- the address that starts the sign-in through the source
Open this address in a private browser window, through the proxy. Tinyauth asks for its sign-in, and FileRun then signs you in.
Important
The superuser can always sign in with the local password. Keep
Allow local user accounts to log inenabled until you are sure the setup works, so that the other local user accounts can still sign in with their passwords.
Signing in
The sign-in page shows the button of the source, "Sign in with" followed by the name of the source. A click on the button signs the person in at once, because the person is already signed in to Tinyauth.
At the first sign-in of a Tinyauth user, FileRun creates the user account:
- The username is the value of
Remote-User. - The first name is the full name of
Remote-Name. The last name stays empty. - The e-mail address is the value of
Remote-Email. - The account is linked to the username of
Remote-User, without regard to upper and lower case.
FileRun refuses the sign-in with "The request did not come through the proxy of Tinyauth." when the
request does not come from a trusted address, and with "Tinyauth did not send the user." when the
request has no Remote-User header.
Security
FileRun trusts the headers in every request that comes from a trusted address. So only the proxy of Tinyauth may reach FileRun from these addresses. Make sure that no other program can reach FileRun from them.
When a web server or a proxy of your own runs between the proxy of Tinyauth and FileRun, FileRun sees the address of that server. Trust that address only when every request that reaches it comes through the proxy of Tinyauth.
The Trusted addresses of the source are not the Trusted proxies of FileRun. A trusted proxy
reports the IP address of the visitor, and it does not have to remove the headers of a client. So
the source does not use the trusted proxies. Add the address of the proxy to the Trusted proxies
too, so that the activity log shows the addresses of the visitors. See
Trusted proxies.
Signing out
With both plugins, signing out of FileRun ends the FileRun session only. Tinyauth has no sign-out
address for the applications, and the session of Tinyauth continues. With Tinyauth Forward Auth,
the sign-in button then signs the person in again at once. To end both sessions, sign out of
Tinyauth as well.