owncloud-archive / sociallogin

GNU Affero General Public License v3.0
3 stars 5 forks source link

Self-Hosted GitLab Integration #5

Open w1ndy opened 5 years ago

w1ndy commented 5 years ago

Hi all,

I've been trying to set up Open ID Connect authentication with a self-hosted GitLab instance, but the plugin keeps complaining that identifier is null while being inserted into the database:

{"reqId":"wNSsfliJCJIHXNpbr6N2","level":3,"time":"2019-06-05T17:25:26+08:00","remoteAddr":"192.168.160.1","user":"wengdi","app":"index","method":"GET","url":"\/apps\/sociallogin\/custom_oidc\/gitlab","message":"Caused by: {\"Exception\":\"PDOException\",\"Message\":\"SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'identifier' cannot be null\",\"Code\":\"23000\",\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/PDOStatement.php(105): PDOStatement->execute(NULL)\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(168): Doctrine\\\\DBAL\\\\Driver\\\\PDOStatement->execute(NULL)\\n#2 \\\/mnt\\\/data\\\/apps\\\/sociallogin\\\/lib\\\/Db\\\/SocialConnectDAO.php(42): Doctrine\\\\DBAL\\\\Statement->execute()\\n#3 \\\/mnt\\\/data\\\/apps\\\/sociallogin\\\/lib\\\/Controller\\\/LoginController.php(300): OCA\\\\SocialLogin\\\\Db\\\\SocialConnectDAO->connectLogin('wengdi', NULL)\\n#4 \\\/mnt\\\/data\\\/apps\\\/sociallogin\\\/lib\\\/Controller\\\/LoginController.php(241): OCA\\\\SocialLogin\\\\Controller\\\\LoginController->login(*** sensitive parameters replaced ***)\\n#5 \\\/mnt\\\/data\\\/apps\\\/sociallogin\\\/lib\\\/Controller\\\/LoginController.php(179): OCA\\\\SocialLogin\\\\Controller\\\\LoginController->auth('OCA\\\\\\\\SocialLogin...', Array, 'gitlab', 'OpenID Connect')\\n#6 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(153): OCA\\\\SocialLogin\\\\Controller\\\\LoginController->customOidc('gitlab')\\n#7 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(85): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OCA\\\\SocialLogin\\\\Controller\\\\LoginController), 'customOidc')\\n#8 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/App.php(100): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OCA\\\\SocialLogin\\\\Controller\\\\LoginController), 'customOidc')\\n#9 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(46): OC\\\\AppFramework\\\\App::main('OCA\\\\\\\\SocialLogin...', 'customOidc', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#10 \\\/var\\\/www\\\/owncloud\\\/lib\\\/private\\\/Route\\\/Router.php(342): OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#11 \\\/var\\\/www\\\/owncloud\\\/lib\\\/base.php(909): OC\\\\Route\\\\Router->match('\\\/apps\\\/sociallog...')\\n#12 \\\/var\\\/www\\\/owncloud\\\/index.php(54): OC::handleRequest()\\n#13 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/PDOStatement.php\",\"Line\":105}"}

I did some digging and found out that this part of code (line 280 - 286) reset $uid to null, causing $this->socialConnect->connectLogin($currentUid, $uid) to fail when attempting to insert the arguments into the database (the plugin should have throw the exception, fixed in #4).

However, if I comment out the aforementioned part of code completely, OpenID authentication seems working without any problem. I'm wondering what does this part of code do and if there a better fix? Thank you!