Trang này chưa có bản Tiếng Việt. Đang hiển thị bằng tiếng Anh.
Single Sign-On with GitLab
Needs Balance HTTP tunnels
Trong trang này 4 mục
Let visitors sign in with their GitLab account before they can open an HTTP tunnel. It works with GitLab.com and with a self-managed GitLab instance. You create an OAuth application in GitLab, add it to Localtonet as a provider, then turn it on for the tunnel.
Before you start #
- An HTTP tunnel and Balance on your account. See the Single Sign-On overview.
- A GitLab account on GitLab.com or on your own instance.
- For a self-managed instance: its address must be reachable from the internet. Your visitors' browsers open its sign-in page, and Localtonet's sign-in host calls its token and user endpoints directly.
Steps #
-
Create an OAuth application in GitLab #
GitLab's own guide is Configure GitLab as an OAuth 2.0 authentication identity provider. An application can belong to a user, a group or the whole instance:
Owner Where to create it Your user Select your avatar, then Edit profile, then Access › Applications and Add new application. A group Open the group, then Settings › Applications. The instance (self-managed, administrators only) Admin › Applications and New application. Fill in the form and select Save application:
GitLab field Value Name A name your visitors recognize. GitLab shows it when it asks them to authorize. Redirect URI http://auth.localtonet.com/auth/callbackConfidential Keep it selected. Scopes read_userGitLab then shows the Application ID and the Secret. Copy both right away: GitLab shows the secret only immediately after the application is created.
The
read_userscope gives read access to the profile of the signed-in user through the/api/v4/userendpoint, which is the User info endpoint Localtonet fills in. It is the only scope the sign-in requests, so the application needs no other scope. -
Add the provider in Localtonet #
Open My Tunnels › HTTP and select SSO at the top of the page. In the SSO providers dialog, select Add provider.
Field Value Provider name Any name, for example Company GitLab. You see it in the tunnel settings.Provider type GitLab. Changing the type of a saved provider empties Client ID, so enter the client ID and the client secret again. Active On Client ID The Application ID from GitLab. Client secret The Secret from GitLab. It is never displayed after saving. Open Endpoints & callback. The addresses of GitLab.com are filled in automatically. For a self-managed instance, replace
gitlab.comwith the host name of your instance in the first three fields.GitLab.com
Field Filled-in value Authorization endpoint https://gitlab.com/oauth/authorizeToken endpoint https://gitlab.com/oauth/tokenUser info endpoint https://gitlab.com/api/v4/userCallback path /auth/callback/gitlabSelf-managed
Field Value to enter Authorization endpoint https://<YOUR_GITLAB_HOST>/oauth/authorizeToken endpoint https://<YOUR_GITLAB_HOST>/oauth/tokenUser info endpoint https://<YOUR_GITLAB_HOST>/api/v4/userCallback path /auth/callback/gitlab(unchanged)The Redirect URI in the GitLab application stays the Localtonet address from step 1. It does not contain your GitLab host.
Optionally fill in Email access rules, then select Save provider.
-
Turn it on for a tunnel #
Under Your tunnels, select Settings on the tunnel, then Manage next to SSO Providers. In the Single sign-on dialog, turn on Require sign-in and the switch of your GitLab provider. Select Save.
On GitLab.com anyone can create an account. Without a rule, every GitLab.com user who knows the address can open the tunnel. Fill in Who can sign in on the tunnel, or Allowed email domains on the provider. The lists are explained in the overview.
-
Test it #
Open the tunnel URL in a private browser window. Localtonet shows Sign in to continue with a button for your provider. GitLab asks you to authorize the application the first time. After that you are sent back to the tunnel and your service loads.
Troubleshooting #
GitLab says the redirect URI included is not valid
No Redirect URI of the GitLab application matches the address that was sent. Enter exactly http://auth.localtonet.com/auth/callback as the Redirect URI of the application.
GitLab says the requested scope is invalid, unknown, or malformed
A scope that was requested is not selected in the GitLab application. Edit the application and select read_user.
GitLab says the client authentication failed
The Client ID or the Client secret saved in Localtonet does not match the GitLab application. Paste the Application ID and the Secret again and select Save provider. If you renew the secret in GitLab, the application stops working until you save the new secret in Localtonet.
Sign-in with a self-managed instance never completes
Check the three endpoints for typing mistakes and make sure the instance answers from the internet. If it uses HTTPS, it needs a certificate that public clients trust. An instance that is reachable only inside your network cannot be used.
"403 - Access Denied" after a successful GitLab sign-in
A Localtonet rule refused the account. Check Email access rules on the provider and Who can sign in on the tunnel. After you correct a rule, wait a minute and reload.
There is no GitLab button on the sign-in page
The provider is not turned on for this tunnel, or it is set to inactive. Check both.