6.4 KiB
title, description
| title | description |
|---|---|
| Nextcloud | Set up Pocket ID authentication for Nextcloud |
Nextcloud does not come with OIDC/SSO installed out-of-the-box. Therefore, it's necessary to install a Nextcloud app for this functionality. There are two main options: nextcloud/user_oidc and pulsejet/nextcloud-oidc-login. This guide will focus on nextcloud/user_oidc, as it is maintained by Nextcloud and is expected to be supported longer.
The following example variables are used and should be replaced with your actual URLs:
nextcloud.example.com(The URL of your Nextcloud instance.)id.example.com(The URL of your Pocket ID instance.)
Pocket ID Setup
- In Pocket ID create a new OIDC Client, name it, for example,
Nextcloud. - Set a logo for this OIDC Client if you would like to.
- Set the callback URL to:
https://nextcloud.example.com/apps/user_oidc/code, or leave blank to autofill on first login. - Set the Logout Callback URLs to the address the nextcloud/user_oidc plugin will give you. For most of the time it will be the address below with the portion
PocketIDbeing the name you gave to it on Nextcloud. e.g:https://nextcloud.example.com/apps/user_oidc/backchannel-logout/PocketID. - Leave
Public ClientandPKCEunchecked. - Copy the
Client ID,Client Secret,OIDC Discovery URLandLogout URLfor use in the next steps.
Nextcloud Setup
-
Login to Nextcloud with your admin account.
-
On the right upper corner, click your profile picture/logo and select
Apps -
On
IntegrationselectOpenID Connect user backendand install it. -
After installing, go to
Administration settings->OpenID Connect. -
Click the
+and add the information and add the information as follows:-
Identifier->PocketID(suggestion only) -
Client ID->Client IDfrom Pocket ID -
Client secret->Client Secretfrom Pocket ID -
Discovery endpoint->OIDC Discovery URLfrom Pocket ID -
Custom end session endpoint->Logout URLfrom Pocket ID -
Scope->openid email profile groups -
By default, Nextcloud will create a new user when logging in using Pocket ID. If you want to log in with an existing Nextcloud user, you need to tell Nextcloud how to match Pocket ID users with Nextcloud users. You can either:
-
Match accounts using a custom claim:
User ID mapping-> nextcloud_usernameAnd for each user in the Pocket ID configuration, add a custom claim
nextcloud_username-> the Nextcloud account name to log into. -
If you have unchecked
Enable Self-Account Editingin the Pocket ID configuration, match accounts using the Pocket ID username directly:User ID mapping-> preferred_username(if
Enable Self-Account Editingis enabled, Pocket ID users are allowed to change their own username and therefore chose the Nextcloud account they log into!)
-
-
(Optional) Open Extra-Attribute-Mapping and set Avatar-Mapping to
picture. This downloads the Profilpicture from PocketID -
(Optional) Check
Use group provisioningif you want Pocket ID groups to be replicated on Nextcloud -
(Optional) If you're using groups you can whitelist them using Group-Whitelist-Regex ->
^(nextcloud_(admins|users))$. This Regex will look for both groups nextcloud_admins and nextcloud_users. By enabling the next point User Login only matching Whitelist-Regex only users in this groups will have access. -
Use unique user ID-> Checked,Send ID token hint on logout-> Unchecked
-
-
After the creation of the Provider, make sure
Backchannel Logout URLandRedirect URImatches the setting on Pocket ID.
Logging In on Nextcloud on mobile (Important)
The mobile app for Nextcloud on IOS does not accept passkey input, which create a small barrier when using Pocket ID. If you didn't disable regular login, you can use your Nextcloud username and password to login. If you disabled the regular login, you have to create a Login Codeon your Pocket ID dashboard (id.example.com). After getting the Login Code, go to the Nextcloud app, add your Nextcloud URL (nextcloud.example.com). When Pocket ID login appears, select Don't have access to your passkey?, select Login Codeand enter the code you received previously.
Disabling traditional login In on Nextcloud
You can disable the built-in login form with 2 different ways, which are going to produce slightly different outcomes:
-
Disabling login form: On the
config.phpof Nextcloud, set an entry for'hide_login_form' => true. This will still show Nextcloud login page when going tonextcloud.example.com, but it show that "The Nextcloud login form is disabled." and a button toLogin with PocketIDwill appear instead. 1. The login form is only hidden and can be access by appending login?direct=1 to the URLnextcloud.example.com/login?direct=1. -
Remove built-in login form: You have to execute a command inside the container using Nextcloud CLI method. Since there are many containers and platforms, please make sure use the appropriate form for you container/platform combo
- Run ->
occ config:app:set user_oidc allow_multiple_user_backends --value=0 - The built-in login form won't be available anymore when going to
nextcloud.example.comand will be automatically redirected to login with Pocket ID - This only works if the user have a single OIDC provider and no other login methods
- Run ->
Troubleshooting if you can't login into Nextcloud
- Using Nextcloud CLI, reactivate the login form:
occ config:app:set user_oidc allow_multiple_user_backends --value=1 - Remove current ODIC configuration with
occ user_oidc:provider:delete PocketID. SubstitutePocketIDto the name you used or the one listed onuser_oidc:provider - Create a new OIDC connection with the command below. Make sure to adjust as appropriate.
- After the command is run and you can login back to Nextcloud, make sure to adjust the
Scopeand - occ user*oidc:provider
Identifier
--clientid="Client ID"
--clientsecret="Client secret"
--discoveryuri="OIDC Discovery URL"
--mapping-uid="preferred_username"
--unique-uid=1
--send-id-token-hint=0 *(Note: Replace 'Identifier', "Client ID", "Client Secret", and "OIDC Discovery URL" with your actual values.)_
- After the command is run and you can login back to Nextcloud, make sure to adjust the