pulsejet / nextcloud-oidc-login

Nextcloud login via a single OpenID Connect 1.0 provider
https://apps.nextcloud.com/apps/oidc_login
GNU Affero General Public License v3.0
226 stars 61 forks source link

webdav bearer auth problem #129

Closed quenenni closed 2 years ago

quenenni commented 2 years ago

Hello,

Big thanks for your plugin and the new ability to connect via webdav, that's amazing.

I have LemonLdap as my IDP and Nextcloud / Roundcube behind. I configured the Roundcube carddav plugin in order to have Nc addressbooks automatically added to Roundcube sessions using bearer auth.

I were able to make it work, but to achieve that, I had to hack a line in "./lib/Service/LoginService.php" (line 86),

From this:
$uid = $profile[$attr['id']];
To this:
$uid = $profile['sub'];

The problem is it couldn't retrieve my uid from the profile data. And I don't know if it's a problem with the code or a bad configuration from me in LemonLdap (I'll tend for the latter)

Here are the data the class loginService has:

Array attr:
  id => preferred_username
  name => name
  mail => email
  quota => nextCloudQuota
  home => homeDirectory
  ldap_uid => uid            ( the option "oidc_login_proxy_ldap" is set to false in Nc config)
  groups => groupsNc
  is_admin => adminNc

Array profile:
  jti => 9cb97612.........086edb95
  iat => 163.....856
  aud => Array
  aud_0 => rp-roundcube
  aud_rp-roundcube => rp-roundcube
  aud_1 => rp-nextcloud
  aud_rp-nextcloud => rp-nextcloud
  iss => https://auth.mydomain.tld
  scope => email profile openid
  client_id => rp-roundcube
  sub => test1
  exp => 1636047456

The line 86 is trying to get the uid from "$profile[$attr['id']]" ( = $profile["preferred_username"]), but the profile array doesn't include that information, so the uid is null and an error is returned.

If I change line 86 by "$uid = $profile['sub'];", then it works and my addressbook is auto added in my Roundcube.

Why can't Nextcloud ask for the "preferred_username" value to the Idp (LemonLdap). That attribute is in the scope. And Nc is able to retrieve it when I connect to the web Ui.

At this point, I'm uncertain what path to take to fix this.

Thanks, Kenny

quenenni commented 2 years ago

I was simply blind. I had 2 lines with 'id' attr in config.php and it took me hours to notice it.

Sorry for the noise.