Added OIDC client code

This commit is contained in:
Alexandre Bourlier 2018-06-19 23:59:50 +02:00
parent c5e18374bc
commit de33cc7885
3 changed files with 50 additions and 1 deletions

View File

@ -4,7 +4,7 @@ HD app is the magic tool that allows the Happy Dev network to thrive in a decent
* `git clone --recurse-submodules https://git.happy-dev.fr/happy-dev/hd-app.git`
* `cd hd-app`
* `cp config-sample.php config.php`
* Edit `config.php` to suits your own setup
* Edit `config.php` to suit your own setup
* `npm install -g grunt-cli`
* `npm install`

8
dist/lib/sib-oidc-client-config.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"authority": "http://localhost:8000/openid/",
"client_id": "598550",
"redirect_uri": "http://oidc-client.local/user-manager-sample.html",
"response_type": "id_token token",
"scope": "openid profile email",
"loadUserInfo": true
}

41
dist/lib/sib-oidc-client.js vendored Normal file
View File

@ -0,0 +1,41 @@
if (typeof Oidc == "undefined") {
throw new Error("You are missing the `oidc-client-js` lib");
}
// Var declarations
var sib = {};
sib.oidc = {};
// Setup User Manager
sib.oidc._setup = function(settings) {
if (typeof sib.oidc._manager == "undefined") {
sib.oidc._manager = new Oidc.UserManager(settings);
}
}
// Connect to OIDC provider
sib.oidc.connect = function (settings) {
sib.oidc._setup(settings);
sib.oidc._manager.signinRedirectCallback()
.then()
.catch(function(error) {
console.log(error);
sib.oidc._manager.signinRedirect({state: "some data"})
.then()
.catch(function(error) {
console.log(error);
});
});
}
// Entry point
fetch("./oidc-client-config.json")
.then(response => response.json())
.then(settings => sib.oidc.connect(settings));