add feide authentication
This commit is contained in:
parent
3d2f07418d
commit
a3c68c3c79
|
@ -0,0 +1,3 @@
|
|||
[submodule "lib/OAuth2-Client"]
|
||||
path = lib/OAuth2-Client
|
||||
url = https://github.com/kasperrt/OAuth2-Client.git
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7b2dc91100becd0c3d15de8764ad279ded0d3a58
|
|
@ -1,4 +1,31 @@
|
|||
<?php
|
||||
require_once '../../lib/OAuth2-Client/OAuth2Client.php';
|
||||
require_once '../../dataporten_config.php';
|
||||
|
||||
$oauth2 = new Kasperrt\Oauth2($dataportenConfig);
|
||||
|
||||
session_start();
|
||||
if (isset($_GET['logout'])) {
|
||||
session_destroy();
|
||||
header('Location: http://[::1]:1080/paamelding/');
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($_GET['code'])) {
|
||||
$token = $oauth2 -> get_access_token();
|
||||
error_log($token);
|
||||
$_SESSION['userdata'] = $oauth2 -> get_identity($token, 'https://auth.dataporten.no/userinfo');
|
||||
header('Location: http://[::1]:1080/paamelding/');
|
||||
die();
|
||||
}
|
||||
if (!isset($_SESSION['userdata'])) {
|
||||
$oauth2 -> redirect();
|
||||
die();
|
||||
}
|
||||
|
||||
//var_export($_SESSION);
|
||||
//exit;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if($_POST["firstname"] == null &&
|
||||
$_POST["lastname"] == null &&
|
||||
|
@ -35,20 +62,16 @@ die();
|
|||
<div>
|
||||
<form>
|
||||
<div>
|
||||
First name:
|
||||
<input type="text" name="firstname">
|
||||
</div>
|
||||
<div>
|
||||
Last name:
|
||||
<input type="text" name="lastname">
|
||||
Full name:
|
||||
<input type="text" name="lastname" value="<?= $_SESSION['userdata']['user']['name'] ?>" readonly>
|
||||
</div>
|
||||
<div>
|
||||
NTNU username:
|
||||
<input type="text" name="username">
|
||||
<input type="text" name="username" value="<?= $_SESSION['userdata']['user']['userid_sec'][0] ?>" readonly>
|
||||
</div>
|
||||
<div>
|
||||
Email adress:
|
||||
<input type="text" name="email">
|
||||
<input type="text" name="email" value="<?= $_SESSION['userdata']['user']['email'] ?>">
|
||||
</div>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
|
Reference in New Issue