Skip to content

Commit

Permalink
Fix wiki auth
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Aug 12, 2023
1 parent 1cd17f2 commit e604e47
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/plugins/authiapconnect2/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,24 @@ public function trustExternal($user, $pass, $sticky = false)
$_SERVER['REMOTE_USER'] = $_SESSION[DOKU_COOKIE]['auth']['user'];
return true;
}

if (!empty($user)) {

$token = $this->getIapToken();

try {
$data = validate_jwt($token, $this->getConf('iap_expected_audience'));
$USERINFO = [
'name' => $data['gcip']['name'],
'mail' => $data['gcip']['email'],
'grps' => array_merge(explode(',',$data['gcip']['groups']), ['user'])
];
} catch (Exception $e) {
return false;
}
$token = $this->getIapToken();

try {
$data = validate_jwt($token, $this->getConf('iap_expected_audience'));
$USERINFO = [
'name' => $data['gcip']['name'],
'mail' => $data['gcip']['email'],
'grps' => array_merge(explode(',',$data['gcip']['groups']), ['user'])
];

$_SERVER['REMOTE_USER'] = $USERINFO['name'];
$_SESSION[DOKU_COOKIE]['auth']['user'] = $USERINFO['name'];
$_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;

return true;
}

return false;
} catch (Exception $e) {
return false;
}
}
}

0 comments on commit e604e47

Please sign in to comment.