# Nextcloud Oauth 2 Login

**URL:** <https://discourse.nodered.org/t/nextcloud-oauth-2-login/4403>\
**Category:** General\
**Tags:** security\
**Created:** [30 October 2018 02:27 UTC](https://discourse.nodered.org/t/nextcloud-oauth-2-login/4403 "2018-10-30T02:27:54Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![dugite-code](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dugite-code/32/3438_2.png) [@dugite-code](https://discourse.nodered.org/u/dugite-code)\
**Post date:** [15 March 2022 06:55 UTC](https://discourse.nodered.org/t/nextcloud-oauth-2-login/4403/8 "2022-03-15T06:55:18Z")

</div>

Finally got user accounts using authentik. Now I just need to get group based permissions at some point.

# SSO Using Authentik

## Preparation

The following placeholders will be used:

```
authentik.company is the FQDN of authentik.
nodered.company is the FQDN of nodered.

```

## Step 1

In authentik, create an OAuth2/OpenID Provider (under Resources/Providers) with these settings:

> note
> 
> Only settings that have been modified from default have been listed.

Protocol Settings

```
Name: nodered
Signing Key: Select any available key

```

> note
> 
> Take note of the Client ID and Client Secret, you'll need to give them to nodered in Step 3.

## Step 2

In authentik, create an application (under Resources/Applications) which uses this provider. Optionally apply access restrictions to the application using policy bindings.  
note

Only settings that have been modified from default have been listed.

```
Name: nodered
Slug: nodered-slug
Provider: nodered

```

## Step 3

> note
> 
> We are assuming node-red is installed under docker

Navigate to the node-red data volume `data/node_modules/`. Alternatively enter the docker container `sudo docker exec -it nodered bash` and `cd /data/node_modules`

Use npm to install passport-openidconnect `npm install passport-openidconnect`

Edit the node-red settings.js file `/data/settings.js`

```auto
adminAuth: {
type:"strategy",
strategy: {
        name: "openidconnect",
        label: 'Sign in with authentik',
        icon:"fa-cloud",
        strategy: require("passport-openidconnect").Strategy,
        options: {
                issuer: 'https://authentik.company/application/o/<application-slug>/',
                authorizationURL: 'https://authentik.company/application/o/authorize/',
                tokenURL: 'https://authentik.company/application/o/token/',
                userInfoURL: 'https://authentik.company/application/o/userinfo/',
                clientID: '<Client ID (Key): Step 2>',
                clientSecret: '<Client Secret: Step 2>',
                callbackURL: 'https://nodered.company/auth/strategy/callback/',
                scope: ['email', 'profile', 'openid'],
                proxy: true,
        verify: function(issuer, profile, done) {
                done(null, profile)
        }
      }
    },
    users: function(user) {
        return Promise.resolve({ username: user, permissions: "*" });
    }
},

```

---

_[View the full topic](https://discourse.nodered.org/t/nextcloud-oauth-2-login/4403)._
