@axa-fr/react-oidc 6.0.0-alpha9 → 6.0.0-beta10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -11
- package/dist/OidcProvider.d.ts +2 -3
- package/dist/OidcProvider.d.ts.map +1 -1
- package/dist/OidcProvider.js +5 -4
- package/dist/OidcProvider.js.map +1 -1
- package/dist/OidcServiceWorker.js +21 -4
- package/dist/OidcTrustedDomains.js +7 -2
- package/dist/core/default-component/SilentCallback.component.d.ts.map +1 -1
- package/dist/core/default-component/SilentCallback.component.js +5 -19
- package/dist/core/default-component/SilentCallback.component.js.map +1 -1
- package/dist/core/default-component/SilentLogin.component.d.ts +4 -0
- package/dist/core/default-component/SilentLogin.component.d.ts.map +1 -0
- package/dist/core/default-component/{SilentSignin.component.js → SilentLogin.component.js} +3 -3
- package/dist/core/default-component/SilentLogin.component.js.map +1 -0
- package/dist/core/routes/OidcRoutes.d.ts +1 -1
- package/dist/core/routes/OidcRoutes.d.ts.map +1 -1
- package/dist/core/routes/OidcRoutes.js +5 -8
- package/dist/core/routes/OidcRoutes.js.map +1 -1
- package/dist/vanilla/checkSessionIFrame.d.ts +6 -6
- package/dist/vanilla/checkSessionIFrame.d.ts.map +1 -1
- package/dist/vanilla/checkSessionIFrame.js +1 -1
- package/dist/vanilla/checkSessionIFrame.js.map +1 -1
- package/dist/vanilla/oidc.d.ts +12 -12
- package/dist/vanilla/oidc.d.ts.map +1 -1
- package/dist/vanilla/oidc.js +342 -236
- package/dist/vanilla/oidc.js.map +1 -1
- package/package.json +2 -2
- package/src/oidc/OidcProvider.tsx +9 -10
- package/src/oidc/core/default-component/SilentCallback.component.tsx +1 -6
- package/src/oidc/core/default-component/{SilentSignin.component.tsx → SilentLogin.component.tsx} +2 -2
- package/src/oidc/core/routes/OidcRoutes.tsx +6 -10
- package/src/oidc/vanilla/OidcServiceWorker.js +21 -4
- package/src/oidc/vanilla/OidcTrustedDomains.js +7 -2
- package/src/oidc/vanilla/checkSessionIFrame.ts +7 -7
- package/src/oidc/vanilla/oidc.ts +238 -195
- package/dist/core/default-component/ServiceWorkerInstall.component.d.ts +0 -4
- package/dist/core/default-component/ServiceWorkerInstall.component.d.ts.map +0 -1
- package/dist/core/default-component/ServiceWorkerInstall.component.js +0 -131
- package/dist/core/default-component/ServiceWorkerInstall.component.js.map +0 -1
- package/dist/core/default-component/SilentSignin.component.d.ts +0 -4
- package/dist/core/default-component/SilentSignin.component.d.ts.map +0 -1
- package/dist/core/default-component/SilentSignin.component.js.map +0 -1
- package/src/App.css +0 -38
- package/src/App.specold.tsx +0 -46
- package/src/App.tsx +0 -96
- package/src/FetchUser.tsx +0 -53
- package/src/Home.tsx +0 -22
- package/src/MultiAuth.tsx +0 -116
- package/src/Profile.tsx +0 -77
- package/src/configurations.ts +0 -70
- package/src/index.css +0 -13
- package/src/index.tsx +0 -9
- package/src/logo.svg +0 -7
- package/src/oidc/core/default-component/ServiceWorkerInstall.component.tsx +0 -60
- package/src/override/AuthenticateError.component.tsx +0 -14
- package/src/override/Authenticating.component.tsx +0 -14
- package/src/override/Callback.component.tsx +0 -13
- package/src/override/Loading.component.tsx +0 -13
- package/src/override/ServiceWorkerNotSupported.component.tsx +0 -15
- package/src/override/SessionLost.component.tsx +0 -21
- package/src/override/style.ts +0 -10
- package/src/setupTests.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceWorkerInstall.component.d.ts","sourceRoot":"","sources":["../../../src/oidc/core/default-component/ServiceWorkerInstall.component.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAsB,aAAa,EAAC,MAAM,OAAO,CAAC;AAMhE,QAAA,MAAM,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAmD5C,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
-
};
|
|
64
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
var react_1 = __importStar(require("react"));
|
|
66
|
-
var AuthenticateError_component_1 = __importDefault(require("./AuthenticateError.component"));
|
|
67
|
-
var oidc_1 = __importDefault(require("../../vanilla/oidc"));
|
|
68
|
-
var Authenticating_component_1 = __importDefault(require("./Authenticating.component"));
|
|
69
|
-
var route_utils_1 = require("../../vanilla/route-utils");
|
|
70
|
-
var ServiceWorkerInstall = function (_a) {
|
|
71
|
-
var callBackError = _a.callBackError, authenticating = _a.authenticating, configurationName = _a.configurationName;
|
|
72
|
-
var getOidc = oidc_1.default.get;
|
|
73
|
-
var _b = (0, react_1.useState)(false), error = _b[0], setError = _b[1];
|
|
74
|
-
var _c = (0, react_1.useState)(true), isLoading = _c[0], setLoading = _c[1];
|
|
75
|
-
var CallbackErrorComponent = callBackError || AuthenticateError_component_1.default;
|
|
76
|
-
var CallbackSuccessComponent = authenticating || Authenticating_component_1.default;
|
|
77
|
-
(0, react_1.useEffect)(function () {
|
|
78
|
-
var isMounted = true;
|
|
79
|
-
var playCallbackAsync = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var queryParams, extras, _i, _a, _b, key, value, error_1;
|
|
81
|
-
return __generator(this, function (_c) {
|
|
82
|
-
switch (_c.label) {
|
|
83
|
-
case 0:
|
|
84
|
-
_c.trys.push([0, 2, , 3]);
|
|
85
|
-
queryParams = (0, route_utils_1.getParseQueryStringFromLocation)(window.location.href);
|
|
86
|
-
extras = null;
|
|
87
|
-
for (_i = 0, _a = Object.entries(queryParams); _i < _a.length; _i++) {
|
|
88
|
-
_b = _a[_i], key = _b[0], value = _b[1];
|
|
89
|
-
if (key === "state" || key == "callbackPath") {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (extras === null) {
|
|
93
|
-
extras = {};
|
|
94
|
-
}
|
|
95
|
-
extras[key] = value;
|
|
96
|
-
}
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
return [4 /*yield*/, getOidc(configurationName).loginAsync(queryParams.callbackPath, extras, false, queryParams.state)];
|
|
99
|
-
case 1:
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
_c.sent();
|
|
102
|
-
if (isMounted) {
|
|
103
|
-
setLoading(false);
|
|
104
|
-
}
|
|
105
|
-
return [3 /*break*/, 3];
|
|
106
|
-
case 2:
|
|
107
|
-
error_1 = _c.sent();
|
|
108
|
-
if (isMounted) {
|
|
109
|
-
setError(true);
|
|
110
|
-
setLoading(false);
|
|
111
|
-
}
|
|
112
|
-
return [3 /*break*/, 3];
|
|
113
|
-
case 3: return [2 /*return*/];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}); };
|
|
117
|
-
playCallbackAsync();
|
|
118
|
-
return function () {
|
|
119
|
-
isMounted = false;
|
|
120
|
-
};
|
|
121
|
-
}, []);
|
|
122
|
-
if (isLoading) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
if (error) {
|
|
126
|
-
return react_1.default.createElement(CallbackErrorComponent, { configurationName: configurationName });
|
|
127
|
-
}
|
|
128
|
-
return react_1.default.createElement(CallbackSuccessComponent, { configurationName: configurationName });
|
|
129
|
-
};
|
|
130
|
-
exports.default = ServiceWorkerInstall;
|
|
131
|
-
//# sourceMappingURL=ServiceWorkerInstall.component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceWorkerInstall.component.js","sourceRoot":"","sources":["../../../src/oidc/core/default-component/ServiceWorkerInstall.component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgE;AAChE,8FAAgE;AAChE,4DAAsC;AACtC,wFAAwD;AACxD,yDAA0E;AAE1E,IAAM,oBAAoB,GAAuB,UAAC,EAAmD;QAAlD,aAAa,mBAAA,EAAE,cAAc,oBAAA,EAAE,iBAAiB,uBAAA;IAC/F,IAAM,OAAO,GAAI,cAAI,CAAC,GAAG,CAAC;IACpB,IAAA,KAAoB,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAlC,KAAK,QAAA,EAAE,QAAQ,QAAmB,CAAC;IACpC,IAAA,KAA0B,IAAA,gBAAQ,EAAC,IAAI,CAAC,EAAvC,SAAS,QAAA,EAAE,UAAU,QAAkB,CAAC;IAE/C,IAAM,sBAAsB,GAAG,aAAa,IAAI,qCAAmB,CAAC;IACpE,IAAM,wBAAwB,GAAG,cAAc,IAAI,kCAAc,CAAC;IAElE,IAAA,iBAAS,EAAC;QACN,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAM,iBAAiB,GAAG;;;;;;wBAEZ,WAAW,GAAG,IAAA,6CAA+B,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBACtE,MAAM,GAAG,IAAI,CAAC;wBAClB,WAAoD,EAA3B,KAAA,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAA3B,cAA2B,EAA3B,IAA2B,EAAE;4BAA7C,WAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;4BAChB,IAAG,GAAG,KAAK,OAAO,IAAI,GAAG,IAAI,cAAc,EAAC;gCACxC,SAAS;6BACZ;4BACD,IAAG,MAAM,KAAK,IAAI,EAAC;gCACf,MAAM,GAAG,EAAE,CAAC;6BACf;4BACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;yBACvB;wBAED,aAAa;wBACb,qBAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,EAAC,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EAAA;;wBADtG,aAAa;wBACb,SAAsG,CAAC;wBACvG,IAAG,SAAS,EAAE;4BACV,UAAU,CAAC,KAAK,CAAC,CAAC;yBACrB;;;;wBAED,IAAG,SAAS,EAAE;4BACV,QAAQ,CAAC,IAAI,CAAC,CAAC;4BACf,UAAU,CAAC,KAAK,CAAC,CAAC;yBACrB;;;;;aAER,CAAC;QACF,iBAAiB,EAAE,CAAC;QACpB,OAAO;YACH,SAAS,GAAG,KAAK,CAAC;QACtB,CAAC,CAAC;IACN,CAAC,EAAC,EAAE,CAAC,CAAC;IAEN,IAAG,SAAS,EAAC;QACT,OAAO,IAAI,CAAC;KACf;IAED,IAAG,KAAK,EAAC;QACL,OAAO,8BAAC,sBAAsB,IAAC,iBAAiB,EAAE,iBAAiB,GAAI,CAAA;KAC1E;IAED,OAAO,8BAAC,wBAAwB,IAAC,iBAAiB,EAAE,iBAAiB,GAAI,CAAC;AAC9E,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SilentSignin.component.d.ts","sourceRoot":"","sources":["../../../src/oidc/core/default-component/SilentSignin.component.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAY,aAAa,EAAC,MAAM,OAAO,CAAC;AAKtD,QAAA,MAAM,YAAY,EAAE,aAAa,CAAC,GAAG,CA2BnC,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SilentSignin.component.js","sourceRoot":"","sources":["../../../src/oidc/core/default-component/SilentSignin.component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsD;AACtD,4DAAsC;AACtC,yDAA0E;AAG1E,IAAM,YAAY,GAAuB,CAAC,UAAC,EAAoB;QAAnB,iBAAiB,uBAAA;IACzD,IAAM,WAAW,GAAG,IAAA,6CAA+B,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE1E,IAAM,OAAO,GAAI,cAAI,CAAC,GAAG,CAAC;IAC1B,IAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAExC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,KAAyB,UAA2B,EAA3B,KAAA,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAA3B,cAA2B,EAA3B,IAA2B,EAAE;QAA7C,IAAA,WAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QAChB,IAAG,GAAG,KAAK,OAAO,IAAI,GAAG,IAAI,OAAO,EAAC;YACjC,SAAS;SACZ;QACD,IAAG,MAAM,KAAK,IAAI,EAAC;YACf,MAAM,GAAG,EAAE,CAAC;SACf;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KACvB;IAED,IAAA,iBAAS,EAAC;QACN,IAAG,CAAC,IAAI,CAAC,MAAM,EAAC;YACZ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;SACnF;QACD,OAAO;QACP,CAAC,CAAA;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,6DAAK,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC"}
|
package/src/App.css
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
.App {
|
|
2
|
-
text-align: center;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.App-logo {
|
|
6
|
-
height: 40vmin;
|
|
7
|
-
pointer-events: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
11
|
-
.App-logo {
|
|
12
|
-
animation: App-logo-spin infinite 20s linear;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.App-header {
|
|
17
|
-
background-color: #282c34;
|
|
18
|
-
min-height: 100vh;
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
align-items: center;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
font-size: calc(10px + 2vmin);
|
|
24
|
-
color: white;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.App-link {
|
|
28
|
-
color: #61dafb;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@keyframes App-logo-spin {
|
|
32
|
-
from {
|
|
33
|
-
transform: rotate(0deg);
|
|
34
|
-
}
|
|
35
|
-
to {
|
|
36
|
-
transform: rotate(360deg);
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/App.specold.tsx
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// __tests__/fetch.test.js
|
|
2
|
-
/*import React from 'react'
|
|
3
|
-
import {rest} from 'msw'
|
|
4
|
-
import {setupServer} from 'msw/node'
|
|
5
|
-
import {render, fireEvent, waitFor, screen} from '@testing-library/react'
|
|
6
|
-
import '@testing-library/jest-dom'
|
|
7
|
-
import App from "./App";
|
|
8
|
-
import {act} from "react-dom/test-utils";
|
|
9
|
-
|
|
10
|
-
const server = setupServer(
|
|
11
|
-
rest.get('http://api/.well-known/openid-configuration', (req, res, ctx) => {
|
|
12
|
-
return res( ctx.status(200),ctx.json({
|
|
13
|
-
"issuer":"https://demo.identityserver.io",
|
|
14
|
-
"jwks_uri":"https://demo.identityserver.io/.well-known/openid-configuration/jwks",
|
|
15
|
-
"authorization_endpoint":"https://demo.identityserver.io/connect/authorize",
|
|
16
|
-
"token_endpoint":"https://demo.identityserver.io/connect/token",
|
|
17
|
-
"userinfo_endpoint":"https://demo.identityserver.io/connect/userinfo",
|
|
18
|
-
"end_session_endpoint":"https://demo.identityserver.io/connect/endsession",
|
|
19
|
-
"check_session_iframe":"https://demo.identityserver.io/connect/checksession",
|
|
20
|
-
"revocation_endpoint":"https://demo.identityserver.io/connect/revocation",
|
|
21
|
-
"introspection_endpoint":"https://demo.identityserver.io/connect/introspect",
|
|
22
|
-
"device_authorization_endpoint":"https://demo.identityserver.io/connect/deviceauthorization","frontchannel_logout_supported":true,"frontchannel_logout_session_supported":true,"backchannel_logout_supported":true,"backchannel_logout_session_supported":true,"scopes_supported":["openid","profile","email","api","api.scope1","api.scope2","scope2","policyserver.runtime","policyserver.management","offline_access"],"claims_supported":["sub","name","family_name","given_name","middle_name","nickname","preferred_username","profile","picture","website","gender","birthdate","zoneinfo","locale","updated_at","email","email_verified"],"grant_types_supported":["authorization_code","client_credentials","refresh_token","implicit","password","urn:ietf:params:oauth:grant-type:device_code"],"response_types_supported":["code","token","id_token","id_token token","code id_token","code token","code id_token token"],"response_modes_supported":["form_post","query","fragment"],"token_endpoint_auth_methods_supported":["client_secret_basic","client_secret_post"],"id_token_signing_alg_values_supported":["RS256"],"subject_types_supported":["public"],"code_challenge_methods_supported":["plain","S256"],"request_parameter_supported":true}))
|
|
23
|
-
}),
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
beforeAll(() => server.listen())
|
|
27
|
-
afterEach(() => server.resetHandlers())
|
|
28
|
-
afterAll(() => server.close())
|
|
29
|
-
|
|
30
|
-
test('Load home page then login should log', async () => {
|
|
31
|
-
|
|
32
|
-
const configuration = {
|
|
33
|
-
client_id: 'interactive.public.short',
|
|
34
|
-
redirect_uri: 'http://localhost:4200/authentication/callback',
|
|
35
|
-
scope: 'openid profile email api offline_access',
|
|
36
|
-
authority: 'http://api',
|
|
37
|
-
refresh_time_before_tokens_expiration_in_second: 70,
|
|
38
|
-
};
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
const {debug, getByText, rerender} = render(<App configuration={configuration}/>);
|
|
41
|
-
await waitFor(() => getByText('React Demo Application protected by OpenId Connect'));
|
|
42
|
-
fireEvent.click(screen.getByText('Login'));
|
|
43
|
-
await waitFor(() => getByText('Authentification en cours'));
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
*/
|
package/src/App.tsx
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React, {useReducer} from 'react';
|
|
2
|
-
import {BrowserRouter, Route, Link, Routes} from 'react-router-dom';
|
|
3
|
-
import { Home } from "./Home";
|
|
4
|
-
import { Profile, SecureProfile } from "./Profile";
|
|
5
|
-
import { configurationAuth0, configurationIdentityServer, configurationIdentityServerWithoutDiscovery } from './configurations';
|
|
6
|
-
import { withOidcSecure, OidcProvider } from "./oidc";
|
|
7
|
-
import {FetchUserHoc, FetchUserHook} from "./FetchUser";
|
|
8
|
-
import { MultiAuthContainer } from "./MultiAuth";
|
|
9
|
-
|
|
10
|
-
const OidcSecureHoc = withOidcSecure(Profile);
|
|
11
|
-
|
|
12
|
-
function reducer(state, action) {
|
|
13
|
-
switch (action.type) {
|
|
14
|
-
case 'event':
|
|
15
|
-
return [{...action.data, date:Date.now()}, ...state]
|
|
16
|
-
default:
|
|
17
|
-
throw new Error();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function App() {
|
|
22
|
-
const [show, setShow] = React.useState(false);
|
|
23
|
-
const [events, dispatch] = useReducer(reducer, []);
|
|
24
|
-
|
|
25
|
-
const onEvent=(configurationName, eventName, data )=>{
|
|
26
|
-
// console.log(`oidc:${configurationName}:${eventName}`, data);
|
|
27
|
-
dispatch({type: 'event', data: {name: `oidc:${configurationName}:${eventName}`, data}})
|
|
28
|
-
}
|
|
29
|
-
return (<>
|
|
30
|
-
|
|
31
|
-
<OidcProvider configuration={configurationIdentityServer} onEvent={onEvent}>
|
|
32
|
-
<BrowserRouter>
|
|
33
|
-
<nav className="navbar navbar-expand-lg navbar-dark bg-primary">
|
|
34
|
-
<a className="navbar-brand" href="/">@axa-fr/react-oidc</a>
|
|
35
|
-
<button className="navbar-toggler" type="button" onClick={() => setShow(!show)} data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
36
|
-
<span className="navbar-toggler-icon"/>
|
|
37
|
-
</button>
|
|
38
|
-
<div style={show ? { display: "block" } : { display: 'none' }} className="collapse navbar-collapse" id="navbarNav">
|
|
39
|
-
<ul className="navbar-nav">
|
|
40
|
-
<li className="nav-item">
|
|
41
|
-
<Link className="nav-link" to="/">Home</Link>
|
|
42
|
-
</li>
|
|
43
|
-
<li className="nav-item">
|
|
44
|
-
<Link className="nav-link" to="/profile">Profile</Link>
|
|
45
|
-
</li>
|
|
46
|
-
<li className="nav-item">
|
|
47
|
-
<Link className="nav-link" to="/profile-secure-component">Secure Profile Component</Link>
|
|
48
|
-
</li>
|
|
49
|
-
<li className="nav-item">
|
|
50
|
-
<Link className="nav-link" to="/profile-secure-hoc">Secure Profile Hoc</Link>
|
|
51
|
-
</li>
|
|
52
|
-
<li className="nav-item">
|
|
53
|
-
<Link className="nav-link" to="/user-fetch-secure-hoc">Secure User Fetch Hoc</Link>
|
|
54
|
-
</li>
|
|
55
|
-
<li className="nav-item">
|
|
56
|
-
<Link className="nav-link" to="/user-fetch-secure-hook">Secure User Fetch Hook</Link>
|
|
57
|
-
</li>
|
|
58
|
-
<li className="nav-item">
|
|
59
|
-
<Link className="nav-link" to="/multi-auth">Multi Auth</Link>
|
|
60
|
-
</li>
|
|
61
|
-
</ul>
|
|
62
|
-
</div>
|
|
63
|
-
</nav>
|
|
64
|
-
|
|
65
|
-
<div>
|
|
66
|
-
<Routes>
|
|
67
|
-
<Route path="/" element={<Home></Home>} />
|
|
68
|
-
<Route path="/profile" element={<Profile></Profile>} />
|
|
69
|
-
<Route path="/profile-secure-component" element={<SecureProfile></SecureProfile>} />
|
|
70
|
-
<Route path="/profile-secure-hoc" element={<OidcSecureHoc></OidcSecureHoc>} />
|
|
71
|
-
<Route path="/user-fetch-secure-hoc" element={<FetchUserHoc></FetchUserHoc>} />
|
|
72
|
-
<Route path="/user-fetch-secure-hook" element={<FetchUserHook></FetchUserHook>} />
|
|
73
|
-
<Route path="/multi-auth/*" element={<MultiAuthContainer></MultiAuthContainer>} />
|
|
74
|
-
</Routes>
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
</BrowserRouter>
|
|
78
|
-
</OidcProvider>
|
|
79
|
-
<div className="container-fluid mt-3">
|
|
80
|
-
<div className="card">
|
|
81
|
-
<div className="card-body" >
|
|
82
|
-
<h5 className="card-title">Default configuration Events</h5>
|
|
83
|
-
<div style={{"overflowX": "hidden", "overflowY": "scroll", "maxHeight": "400px"}}>
|
|
84
|
-
{events.map(e => {
|
|
85
|
-
const date = new Date(e.date);
|
|
86
|
-
const dateFormated = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
|
|
87
|
-
return <p>{dateFormated} {e.name}: { JSON.stringify(e.data)}</p>
|
|
88
|
-
})}
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
</div></>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export default App;
|
package/src/FetchUser.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
2
|
-
|
|
3
|
-
import {useOidcFetch, withOidcFetch} from "./oidc/FetchToken";
|
|
4
|
-
import {OidcSecure} from "./oidc";
|
|
5
|
-
|
|
6
|
-
const DisplayUserInfo = ({ fetch }) => {
|
|
7
|
-
const [oidcUser, setOidcUser] = useState(null);
|
|
8
|
-
const [isLoading, setLoading] = useState(true);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const fetchUserInfoAsync = async () => {
|
|
12
|
-
const res = await fetch("https://demo.duendesoftware.com/connect/userinfo");
|
|
13
|
-
if (res.status != 200) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return res.json();
|
|
17
|
-
};
|
|
18
|
-
let isMounted = true;
|
|
19
|
-
fetchUserInfoAsync().then((userInfo) => {
|
|
20
|
-
if(isMounted) {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
setOidcUser(userInfo)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
return () => {
|
|
26
|
-
isMounted = false;
|
|
27
|
-
};
|
|
28
|
-
},[]);
|
|
29
|
-
|
|
30
|
-
if(isLoading){
|
|
31
|
-
return <>Loading</>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="container mt-3">
|
|
36
|
-
<div className="card text-white bg-success mb-3">
|
|
37
|
-
<div className="card-body">
|
|
38
|
-
<h5 className="card-title">User information</h5>
|
|
39
|
-
{oidcUser != null && <p className="card-text">{JSON.stringify(oidcUser)}</p>}
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
)
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const UserInfoWithFetchHoc = withOidcFetch(fetch)(DisplayUserInfo);
|
|
47
|
-
|
|
48
|
-
export const FetchUserHoc= () => <OidcSecure><UserInfoWithFetchHoc/></OidcSecure>;
|
|
49
|
-
|
|
50
|
-
export const FetchUserHook= () => {
|
|
51
|
-
const {fetch} = useOidcFetch();
|
|
52
|
-
return <OidcSecure><DisplayUserInfo fetch={fetch} /></OidcSecure>
|
|
53
|
-
}
|
package/src/Home.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {useOidc} from "./oidc";
|
|
3
|
-
|
|
4
|
-
export const Home = () => {
|
|
5
|
-
|
|
6
|
-
const { login, logout, isAuthenticated} = useOidc();
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="container-fluid mt-3">
|
|
10
|
-
<div className="card">
|
|
11
|
-
<div className="card-body">
|
|
12
|
-
<h5 className="card-title">Home</h5>
|
|
13
|
-
<p className="card-text">React Demo Application protected by OpenId Connect. More info on about oidc on <a href="https://github.com/AxaGuilDEv/react-oidc">GitHub @axa-fr/react-oidc</a></p>
|
|
14
|
-
{!isAuthenticated && <p><button type="button" className="btn btn-primary" onClick={() => login('/profile')}>Login</button></p>}
|
|
15
|
-
{!isAuthenticated && <p><button type="button" className="btn btn-primary" onClick={() => login('/profile', null, "youhou")}>Login with state</button></p>}
|
|
16
|
-
{isAuthenticated && <p><button type="button" className="btn btn-primary" onClick={() => logout('/profile')}>logout /profile</button></p>}
|
|
17
|
-
{isAuthenticated && <p><button type="button" className="btn btn-primary" onClick={() => logout('')}>logout</button></p>}
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
)
|
|
22
|
-
};
|
package/src/MultiAuth.tsx
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
import {OidcProvider, useOidc, useOidcAccessToken, useOidcIdToken} from "./oidc";
|
|
3
|
-
import { configurationIdentityServer, configurationIdentityServerWithHash, configurationGoogle} from "./configurations";
|
|
4
|
-
import AuthenticatingError from "./override/AuthenticateError.component"
|
|
5
|
-
import Authenticating from "./override/Authenticating.component"
|
|
6
|
-
import Loading from "./override/Loading.component"
|
|
7
|
-
import {CallBackSuccess} from "./override/Callback.component"
|
|
8
|
-
import SessionLost from "./override/SessionLost.component"
|
|
9
|
-
import ServiceWorkerNotSupported from "./override/ServiceWorkerNotSupported.component"
|
|
10
|
-
|
|
11
|
-
const MultiAuth = ( {configurationName, handleConfigurationChange }) => {
|
|
12
|
-
const { login, logout, isAuthenticated} = useOidc(configurationName);
|
|
13
|
-
const [fname, setFname] = useState("")
|
|
14
|
-
|
|
15
|
-
const handleChange = e => {
|
|
16
|
-
setFname(e.target.value)
|
|
17
|
-
}
|
|
18
|
-
return (
|
|
19
|
-
<div className="container-fluid mt-3">
|
|
20
|
-
<div className="card">
|
|
21
|
-
<div className="card-body">
|
|
22
|
-
<h5 className="card-title">Multiple Authentication</h5>
|
|
23
|
-
<form>
|
|
24
|
-
<label>
|
|
25
|
-
First Name:{" "}
|
|
26
|
-
<input type="text" value={fname} onChange={handleChange} />
|
|
27
|
-
</label>
|
|
28
|
-
</form>
|
|
29
|
-
<p className="card-text">React Demo Application protected by OpenId Connect with MultipleAuthentication.
|
|
30
|
-
<br/>For example, config_1 can have other sensitive scope, config_2 does not ask for the "offline_access" so it does not retrieve the most sensitive token "refresh_token" for very sensitive operation, it retrive only access_token valid for a small amout of time.</p>
|
|
31
|
-
<select value={configurationName} onChange={handleConfigurationChange} >
|
|
32
|
-
<option value="config_classic">config_classic</option>
|
|
33
|
-
<option value="config_without_refresh_token">config_without_refresh_token</option>
|
|
34
|
-
<option value="config_google">google</option>
|
|
35
|
-
<option value="config_with_hash">config_with_hash</option>
|
|
36
|
-
</select>
|
|
37
|
-
{!isAuthenticated && <button type="button" className="btn btn-primary" onClick={() => login()}>Login</button>}
|
|
38
|
-
{isAuthenticated && <button type="button" className="btn btn-primary" onClick={() => logout()}>logout</button>}
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
if(!sessionStorage.configurationName){
|
|
46
|
-
sessionStorage.configurationName = "config_classic";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const MultiAuthContainer = () => {
|
|
50
|
-
const [isSessionLost, setIsSessionLost] = useState(false)
|
|
51
|
-
const [configurationName, setConfigurationName] = useState(sessionStorage.configurationName);
|
|
52
|
-
const callBack = window.location.origin+"/multi-auth/authentification/callback2";
|
|
53
|
-
const silent_redirect_uri = window.location.origin+"/multi-auth/authentification/silent-callback2";
|
|
54
|
-
const configurations = {
|
|
55
|
-
config_classic: {...configurationIdentityServer,
|
|
56
|
-
redirect_uri:callBack,
|
|
57
|
-
silent_redirect_uri,
|
|
58
|
-
scope: 'openid profile email api offline_access'
|
|
59
|
-
},
|
|
60
|
-
config_without_refresh_token: {...configurationIdentityServer,
|
|
61
|
-
redirect_uri:callBack,
|
|
62
|
-
silent_redirect_uri: "",
|
|
63
|
-
scope: 'openid profile email api'},
|
|
64
|
-
config_google: { ...configurationGoogle },
|
|
65
|
-
config_with_hash: { ...configurationIdentityServerWithHash}
|
|
66
|
-
}
|
|
67
|
-
const handleConfigurationChange = (event) => {
|
|
68
|
-
const configurationName = event.target.value;
|
|
69
|
-
sessionStorage.configurationName = configurationName;
|
|
70
|
-
setConfigurationName(configurationName);
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const onSessionLost = ()=>{
|
|
75
|
-
setIsSessionLost(true);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
<OidcProvider configuration={configurations[configurationName]}
|
|
81
|
-
configurationName={configurationName}
|
|
82
|
-
loadingComponent={Loading}
|
|
83
|
-
authenticatingErrorComponent={AuthenticatingError}
|
|
84
|
-
authenticatingComponent={Authenticating}
|
|
85
|
-
serviceWorkerNotSupportedComponent={ServiceWorkerNotSupported}
|
|
86
|
-
callbackSuccessComponent={CallBackSuccess}
|
|
87
|
-
onSessionLost={onSessionLost}
|
|
88
|
-
>
|
|
89
|
-
{ isSessionLost && <SessionLost configurationName={configurationName}/>}
|
|
90
|
-
<MultiAuth configurationName={configurationName} handleConfigurationChange={handleConfigurationChange} />
|
|
91
|
-
<DisplayAccessToken configurationName={configurationName} />
|
|
92
|
-
</OidcProvider>
|
|
93
|
-
</>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const DisplayAccessToken = ({configurationName}) => {
|
|
98
|
-
const{ accessToken, accessTokenPayload } = useOidcAccessToken(configurationName);
|
|
99
|
-
const{ idTokenPayload } = useOidcIdToken(configurationName);
|
|
100
|
-
|
|
101
|
-
if(!accessToken){
|
|
102
|
-
return <p>you are not authentified</p>
|
|
103
|
-
}
|
|
104
|
-
return (
|
|
105
|
-
<div className="card text-white bg-info mb-3">
|
|
106
|
-
<div className="card-body">
|
|
107
|
-
<h5 className="card-title">Access Token</h5>
|
|
108
|
-
<p style={{color:'red', "backgroundColor": 'white'}}>Please consider to configure the ServiceWorker in order to protect your application from XSRF attacks. "access_token" and "refresh_token" will never be accessible from your client side javascript.</p>
|
|
109
|
-
{<p className="card-text">Access Token: {JSON.stringify(accessToken)}</p>}
|
|
110
|
-
{accessTokenPayload != null && <p className="card-text">Access Token Payload: {JSON.stringify(accessTokenPayload)}</p>}
|
|
111
|
-
<h5 className="card-title">Id Token</h5>
|
|
112
|
-
{idTokenPayload != null && <p className="card-text">Access Token Payload: {JSON.stringify(idTokenPayload)}</p>}
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
)
|
|
116
|
-
};
|
package/src/Profile.tsx
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {OidcSecure, useOidcAccessToken, useOidcIdToken, useOidcUser, OidcUserStatus} from "./oidc";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const DisplayUserInfo = () => {
|
|
7
|
-
const{ oidcUser, oidcUserLoadingState } = useOidcUser();
|
|
8
|
-
|
|
9
|
-
switch (oidcUserLoadingState){
|
|
10
|
-
case OidcUserStatus.Loading:
|
|
11
|
-
return <p>User Information are loading</p>;
|
|
12
|
-
case OidcUserStatus.Unauthenticated:
|
|
13
|
-
return <p>you are not authenticated</p>;
|
|
14
|
-
case OidcUserStatus.LoadingError:
|
|
15
|
-
return <p>Fail to load user information</p>;
|
|
16
|
-
default:
|
|
17
|
-
return (
|
|
18
|
-
<div className="card text-white bg-success mb-3">
|
|
19
|
-
<div className="card-body">
|
|
20
|
-
<h5 className="card-title">User information</h5>
|
|
21
|
-
<p className="card-text">{JSON.stringify(oidcUser)}</p>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Profile = () => {
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="container mt-3">
|
|
32
|
-
<DisplayAccessToken/>
|
|
33
|
-
<DisplayIdToken/>
|
|
34
|
-
<DisplayUserInfo/>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const DisplayAccessToken = () => {
|
|
40
|
-
const{ accessToken, accessTokenPayload } = useOidcAccessToken();
|
|
41
|
-
|
|
42
|
-
if(!accessToken){
|
|
43
|
-
return <p>you are not authenticated</p>
|
|
44
|
-
}
|
|
45
|
-
return (
|
|
46
|
-
<div className="card text-white bg-info mb-3">
|
|
47
|
-
<div className="card-body">
|
|
48
|
-
<h5 className="card-title">Access Token</h5>
|
|
49
|
-
<p style={{color:'red', "backgroundColor": 'white'}}>Please consider to configure the ServiceWorker in order to protect your application from XSRF attacks. "access_token" and "refresh_token" will never be accessible from your client side javascript.</p>
|
|
50
|
-
{<p className="card-text">Access Token: {JSON.stringify(accessToken)}</p>}
|
|
51
|
-
{accessTokenPayload != null && <p className="card-text">Access Token Payload: {JSON.stringify(accessTokenPayload)}</p>}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const DisplayIdToken =() => {
|
|
59
|
-
const{ idToken, idTokenPayload } = useOidcIdToken();
|
|
60
|
-
|
|
61
|
-
if(!idToken){
|
|
62
|
-
return <p>you are not authenticated</p>
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className="card text-white bg-info mb-3">
|
|
67
|
-
<div className="card-body">
|
|
68
|
-
<h5 className="card-title">ID Token</h5>
|
|
69
|
-
{<p className="card-text">IdToken: {JSON.stringify(idToken)}</p>}
|
|
70
|
-
{idTokenPayload != null && <p className="card-text">IdToken Payload: {JSON.stringify(idTokenPayload)}</p>}
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export const SecureProfile = () => <OidcSecure><Profile /></OidcSecure>;
|