OAuth2, OAuth providers, SAML, SQRL, Windows SSO, passkeys, two-factor, passwordless, session cookies, password hashing, autologin, multitenancy, Nextcloud, Oracle, Zitadel and the Let's Encrypt setup, each in the same order, checked against the code. Corrected where the code had moved on: passwordless codes are 10 characters for 15 minutes and are not counted by the lockout; an OAuth2 login merges an existing account only when enabled and the email is verified; the Admin Panel sections are under People; the two-factor entry is hidden only on Sandstorm and for OAuth2 accounts; the Zitadel example no longer turns on B2C; Rocket.Chat's claim is preferred_username. Thanks to xet7 !
5.4 KiB
Login with Nextcloud
What it is
Nextcloud users can sign in to WeKan with their Nextcloud account, in two ways. With OAuth2, Nextcloud is the identity provider of WeKan's generic OAuth2 / OIDC login, and the sign-in page has a "Sign in with Oidc" button. With the Nextcloud ExApp, WeKan runs as an external app inside Nextcloud (AppAPI), and the Nextcloud user is signed in to WeKan automatically, with no WeKan sign-in page at all.
Read more
- Nextcloud at Wikipedia
- Nextcloud OAuth2 in the Nextcloud admin manual
- Nextcloud AppAPI and external apps
- WeKan for Nextcloud: building, publishing and integrations
- OAuth2 / OIDC, the generic login Nextcloud plugs into
- Pull requests: Implemented Nextcloud OAuth2 Hack, issue #1874 and Improving documentation for Nextcloud integration
How to use it
OAuth2 login
-
In Nextcloud open
https://your.nextcloud/index.php/settings/admin/securityand add an OAuth 2.0 client. Usehttps://your.wekan/_oauth/oidc(your WeKanROOT_URLfollowed by/_oauth/oidc) as the redirect URI. Write down the client identifier and the secret. -
Set WeKan's environment (or Admin Panel / People / OAuth2):
OAUTH2_ENABLED=true OAUTH2_CLIENT_ID=xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx OAUTH2_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OAUTH2_SERVER_URL=https://your-nextcloud.tld OAUTH2_AUTH_ENDPOINT=/index.php/apps/oauth2/authorize OAUTH2_USERINFO_ENDPOINT=/ocs/v2.php/cloud/user?format=json OAUTH2_TOKEN_ENDPOINT=/index.php/apps/oauth2/api/v1/token OAUTH2_ID_MAP=id OAUTH2_USERNAME_MAP=id OAUTH2_FULLNAME_MAP=display-name OAUTH2_EMAIL_MAP=emailThe same lines are commented out under
==== OAUTH2 Nextcloud ====in docker-compose.yml. -
Restart WeKan (or save in the Admin Panel) and click Sign in with Oidc on the sign-in page.
Users of one Nextcloud often share no email domain; give every new OAuth2
account an organization with OAUTH2_DEFAULT_ORGANIZATION (see
OAuth2).
Nextcloud ExApp
- Install the WeKan external app in Nextcloud 32-35 with a HaRP deploy daemon, as described in WeKan for Nextcloud.
- Set
NEXTCLOUD_ADMIN_USERSto a JSON array of the exact Nextcloud user ids who are WeKan administrators, for example["admin"]. - Open WeKan from Nextcloud. The Nextcloud user is signed in.
How the numbers are calculated
Nextcloud login has no numbers of its own. The ExApp identity it accepts is
limited: the signed identity payload is at most 4096 characters, the signature
is 64 hex characters (HMAC-SHA-256), and a user id is 1-255 characters without
control characters. The WeKan user id is nc- followed by the SHA-256 of the
Nextcloud URL and user id (server/lib/nextcloudIdentity.js).
How it works in WeKan
OAuth2. Nextcloud's user info answer is wrapped in ocs.data;
packages/wekan-oidc/oidc_server.js
unwraps it ("Nextcloud hack"), and the rest is the generic OAuth2 login.
ExApp, only when NEXTCLOUD_EXAPP=true:
- The in-container gateway checks AppAPI's headers and replaces the identity
headers with
x-wekan-nextcloud-userand an HMAC signature made withWEKAN_NEXTCLOUD_PROXY_KEY, a random key only the gateway and WeKan know. - server/lib/nextcloudIdentity.js
verifies the signature and the issuer (
NEXTCLOUD_URL), and derives the user id and the admin flag (NEXTCLOUD_ADMIN_USERS). - server/nextcloud.js registers the
nextcloudlogin handler, creates the account on the first visit (never linking by email or username), keepsisAdminin step withNEXTCLOUD_ADMIN_USERS, refuses a disabled account, and makes every login (resume tokens too) match the identity of the connection. - server/lib/nextcloudTransport.js keeps the verified identity bound to the WebSocket before SockJS drops custom headers.
- client/nextcloud.js logs in with
{ nextcloud: true }when the server says it runs as an ExApp. - Tests: tests/nextcloudLogin.test.cjs, tests/nextcloudIdentity.test.cjs, tests/nextcloudTransport.test.cjs and the live Nextcloud runs in tests/nextcloud.