@steedos/accounts 2.5.3-beta.21 → 2.5.3-beta.23
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/package.json +6 -6
- package/lib/oauth2/client.js +0 -1
- package/lib/oauth2/client.js.map +0 -1
- package/lib/oauth2/config.js +0 -14
- package/lib/oauth2/config.js.map +0 -1
- package/lib/oauth2/consent.js +0 -192
- package/lib/oauth2/consent.js.map +0 -1
- package/lib/oauth2/login.js +0 -166
- package/lib/oauth2/login.js.map +0 -1
- package/lib/oauth2/logout.js +0 -60
- package/lib/oauth2/logout.js.map +0 -1
- package/lib/oauth2/stub/oidc-cert.js +0 -67
- package/lib/oauth2/stub/oidc-cert.js.map +0 -1
- package/lib/saml-idp/config.js +0 -82
- package/lib/saml-idp/config.js.map +0 -1
- package/lib/saml-idp/connectedApps.js +0 -20
- package/lib/saml-idp/connectedApps.js.map +0 -1
- package/lib/saml-idp/express-middleware.js +0 -684
- package/lib/saml-idp/express-middleware.js.map +0 -1
- package/lib/saml-idp/index.js +0 -13
- package/lib/saml-idp/index.js.map +0 -1
- package/lib/saml-idp/simpleProfileMapper.js +0 -75
- package/lib/saml-idp/simpleProfileMapper.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/accounts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.5.3-beta.
|
|
4
|
+
"version": "2.5.3-beta.23",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"/package.json",
|
|
@@ -56,20 +56,20 @@
|
|
|
56
56
|
"validator": "^13.6.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@steedos/auth": "2.5.3-beta.
|
|
60
|
-
"@steedos/meteor-bundle-runner": "2.5.3-beta.
|
|
61
|
-
"@steedos/objectql": "2.5.3-beta.
|
|
59
|
+
"@steedos/auth": "2.5.3-beta.23",
|
|
60
|
+
"@steedos/meteor-bundle-runner": "2.5.3-beta.23",
|
|
61
|
+
"@steedos/objectql": "2.5.3-beta.23",
|
|
62
62
|
"@types/dotenv-flow": "^3.0.0",
|
|
63
63
|
"@types/node": "12.6.8",
|
|
64
64
|
"cross-env": "^7.0.3",
|
|
65
65
|
"dotenv": "^8.2.0",
|
|
66
66
|
"dotenv-flow": "^3.1.0",
|
|
67
67
|
"nodemon": "^2.0.19",
|
|
68
|
-
"steedos-server": "2.5.3-beta.
|
|
68
|
+
"steedos-server": "2.5.3-beta.23",
|
|
69
69
|
"typescript": "4.6.3"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "8fd9cf35d29f8f71e11790bd010bf5b045e7ebc4"
|
|
75
75
|
}
|
package/lib/oauth2/client.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=client.js.map
|
package/lib/oauth2/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/oauth2/client.ts"],"names":[],"mappings":""}
|
package/lib/oauth2/config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hydraAdmin = void 0;
|
|
4
|
-
var hydra_client_1 = require("@oryd/hydra-client");
|
|
5
|
-
var baseOptions = {};
|
|
6
|
-
if (process.env.STEEDOS_MOCK_TLS_TERMINATION) {
|
|
7
|
-
baseOptions.headers = { 'X-Forwarded-Proto': 'https' };
|
|
8
|
-
}
|
|
9
|
-
var hydraAdmin = new hydra_client_1.AdminApi(new hydra_client_1.Configuration({
|
|
10
|
-
basePath: process.env.STEEDOS_HYDRA_ADMIN_URL,
|
|
11
|
-
baseOptions: baseOptions
|
|
12
|
-
}));
|
|
13
|
-
exports.hydraAdmin = hydraAdmin;
|
|
14
|
-
//# sourceMappingURL=config.js.map
|
package/lib/oauth2/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/oauth2/config.ts"],"names":[],"mappings":";;;AAAA,mDAA4D;AAC5D,IAAM,WAAW,GAAQ,EAAE,CAAA;AAE3B,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE;IAC5C,WAAW,CAAC,OAAO,GAAG,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAA;CACvD;AAED,IAAM,UAAU,GAAG,IAAI,uBAAQ,CAC7B,IAAI,4BAAa,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB;IAC7C,WAAW,aAAA;CACZ,CAAC,CACH,CAAA;AAEQ,gCAAU"}
|
package/lib/oauth2/consent.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var express = require("express");
|
|
4
|
-
var url = require("url");
|
|
5
|
-
var config_1 = require("./config");
|
|
6
|
-
var oidc_cert_1 = require("./stub/oidc-cert");
|
|
7
|
-
var _ = require('lodash');
|
|
8
|
-
var csrf = require('csurf');
|
|
9
|
-
var urljoin = require('url-join');
|
|
10
|
-
var pug = require('pug');
|
|
11
|
-
var path = require('path');
|
|
12
|
-
// Sets up csrf protection
|
|
13
|
-
var csrfProtection = csrf({ cookie: true });
|
|
14
|
-
var router = express.Router();
|
|
15
|
-
var getOAuthSession = function (user, grantScope) {
|
|
16
|
-
// The session allows us to set session data for id and access tokens
|
|
17
|
-
var session = {
|
|
18
|
-
// This data will be available when introspecting the token. Try to avoid sensitive information here,
|
|
19
|
-
// unless you limit who can introspect tokens.
|
|
20
|
-
access_token: {
|
|
21
|
-
// foo: 'bar'
|
|
22
|
-
},
|
|
23
|
-
// This data will be available in the ID token.
|
|
24
|
-
id_token: {
|
|
25
|
-
// baz: 'bar'
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var _grantScope = grantScope;
|
|
29
|
-
if (!_.isArray(_grantScope)) {
|
|
30
|
-
_grantScope = [_grantScope];
|
|
31
|
-
}
|
|
32
|
-
_.each(_grantScope, function (scope) {
|
|
33
|
-
if (scope === 'profile') {
|
|
34
|
-
session.id_token.steedos_id = user.steedos_id;
|
|
35
|
-
session.id_token.name = user.name;
|
|
36
|
-
session.id_token.username = user.username;
|
|
37
|
-
session.id_token.mobile = user.mobile;
|
|
38
|
-
session.id_token.email = user.email;
|
|
39
|
-
// (session.id_token as any).job_number = user.job_number;
|
|
40
|
-
session.id_token.locale = user.locale;
|
|
41
|
-
session.id_token.space = user.spaces && user.spaces.length > 0 ? user.spaces[0] : null;
|
|
42
|
-
// (session.id_token as any).profile = user.profile;
|
|
43
|
-
session.id_token.userId = user.userId;
|
|
44
|
-
session.id_token.mobile_verified = user.mobile_verified;
|
|
45
|
-
session.id_token.email_verified = user.email_verified;
|
|
46
|
-
session.id_token.utcOffset = user.utcOffset;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return session;
|
|
50
|
-
};
|
|
51
|
-
router.get('/', csrfProtection, function (req, res, next) {
|
|
52
|
-
// Parses the URL query
|
|
53
|
-
var query = url.parse(req.url, true).query;
|
|
54
|
-
// The challenge is used to fetch information about the consent request from ORY hydraAdmin.
|
|
55
|
-
var challenge = String(query.consent_challenge);
|
|
56
|
-
if (!challenge) {
|
|
57
|
-
next(new Error('Expected a consent challenge to be set but received none.'));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
var user = req.user;
|
|
61
|
-
if (!user) {
|
|
62
|
-
return res.redirect("/accounts/a/#/login?redirect_uri=" + encodeURIComponent(Meteor.absoluteUrl("/oauth2/consent?consent_challenge=".concat(challenge))));
|
|
63
|
-
}
|
|
64
|
-
// This section processes consent requests and either shows the consent UI or
|
|
65
|
-
// accepts the consent request right away if the user has given consent to this
|
|
66
|
-
// app before
|
|
67
|
-
config_1.hydraAdmin
|
|
68
|
-
.getConsentRequest(challenge)
|
|
69
|
-
// This will be called if the HTTP request was successful
|
|
70
|
-
.then(function (_a) {
|
|
71
|
-
var body = _a.data;
|
|
72
|
-
// If a user has granted this application the requested scope, hydra will tell us to not show the UI.
|
|
73
|
-
if (body.skip) {
|
|
74
|
-
// You can apply logic here, for example grant another scope, or do whatever...
|
|
75
|
-
// ...
|
|
76
|
-
// Now it's time to grant the consent request. You could also deny the request if something went terribly wrong
|
|
77
|
-
return config_1.hydraAdmin
|
|
78
|
-
.acceptConsentRequest(challenge, {
|
|
79
|
-
// We can grant all scopes that have been requested - hydra already checked for us that no additional scopes
|
|
80
|
-
// are requested accidentally.
|
|
81
|
-
grant_scope: body.requested_scope,
|
|
82
|
-
// ORY Hydra checks if requested audiences are allowed by the client, so we can simply echo this.
|
|
83
|
-
grant_access_token_audience: body.requested_access_token_audience,
|
|
84
|
-
// The session allows us to set session data for id and access tokens
|
|
85
|
-
session: getOAuthSession(user, body.requested_scope)
|
|
86
|
-
})
|
|
87
|
-
.then(function (_a) {
|
|
88
|
-
var body = _a.data;
|
|
89
|
-
// All we need to do now is to redirect the user back to hydra!
|
|
90
|
-
res.redirect(String(body.redirect_to));
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
// If consent can't be skipped we MUST show the consent UI.
|
|
94
|
-
// return res.status(200).send({
|
|
95
|
-
// csrfToken: (req as any).csrfToken(),
|
|
96
|
-
// challenge: challenge,
|
|
97
|
-
// // We have a bunch of data available from the response, check out the API docs to find what these values mean
|
|
98
|
-
// // and what additional data you have available.
|
|
99
|
-
// requested_scope: body.requested_scope,
|
|
100
|
-
// user: body.subject,
|
|
101
|
-
// client: body.client,
|
|
102
|
-
// action: urljoin(process.env.BASE_URL || '', '/consent')
|
|
103
|
-
// })
|
|
104
|
-
var fn = pug.compileFile(path.join(__dirname, '..', '..', './views/oauth2/consent.pug'), {});
|
|
105
|
-
return res.status(200).send(fn({
|
|
106
|
-
csrfToken: req.csrfToken(),
|
|
107
|
-
challenge: challenge,
|
|
108
|
-
// We have a bunch of data available from the response, check out the API docs to find what these values mean
|
|
109
|
-
// and what additional data you have available.
|
|
110
|
-
requested_scope: body.requested_scope,
|
|
111
|
-
user: body.subject,
|
|
112
|
-
userInfo: user,
|
|
113
|
-
client: body.client,
|
|
114
|
-
action: Meteor.absoluteUrl("/oauth2/consent")
|
|
115
|
-
}));
|
|
116
|
-
})
|
|
117
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
118
|
-
.catch(next);
|
|
119
|
-
// The consent request has now either been accepted automatically or rendered.
|
|
120
|
-
});
|
|
121
|
-
router.post('/', csrfProtection, function (req, res, next) {
|
|
122
|
-
var user = req.user;
|
|
123
|
-
// The challenge is now a hidden input field, so let's take it from the request body instead
|
|
124
|
-
var challenge = req.body.challenge;
|
|
125
|
-
if (!challenge) {
|
|
126
|
-
next(new Error('Expected a consent challenge to be set but received none.'));
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (!user) {
|
|
130
|
-
return res.redirect("/accounts/a/#/login?redirect_uri=" + encodeURIComponent(Meteor.absoluteUrl("/oauth2/consent?consent_challenge=".concat(challenge))));
|
|
131
|
-
}
|
|
132
|
-
// Let's see if the user decided to accept or reject the consent request..
|
|
133
|
-
if (req.body.submit === 'Deny access') {
|
|
134
|
-
// Looks like the consent request was denied by the user
|
|
135
|
-
return (config_1.hydraAdmin
|
|
136
|
-
.rejectConsentRequest(challenge, {
|
|
137
|
-
error: 'access_denied',
|
|
138
|
-
error_description: 'The resource owner denied the request'
|
|
139
|
-
})
|
|
140
|
-
.then(function (_a) {
|
|
141
|
-
var body = _a.data;
|
|
142
|
-
// All we need to do now is to redirect the browser back to hydra!
|
|
143
|
-
res.redirect(String(body.redirect_to));
|
|
144
|
-
})
|
|
145
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
146
|
-
.catch(next));
|
|
147
|
-
}
|
|
148
|
-
// label:consent-deny-end
|
|
149
|
-
var grantScope = req.body.grant_scope;
|
|
150
|
-
if (!Array.isArray(grantScope)) {
|
|
151
|
-
grantScope = [grantScope];
|
|
152
|
-
}
|
|
153
|
-
// The session allows us to set session data for id and access tokens
|
|
154
|
-
var session = getOAuthSession(user, grantScope);
|
|
155
|
-
// Let's fetch the consent request again to be able to set `grantAccessTokenAudience` properly.
|
|
156
|
-
config_1.hydraAdmin
|
|
157
|
-
.getConsentRequest(challenge)
|
|
158
|
-
// This will be called if the HTTP request was successful
|
|
159
|
-
.then(function (_a) {
|
|
160
|
-
var body = _a.data;
|
|
161
|
-
return config_1.hydraAdmin
|
|
162
|
-
.acceptConsentRequest(challenge, {
|
|
163
|
-
// We can grant all scopes that have been requested - hydra already checked for us that no additional scopes
|
|
164
|
-
// are requested accidentally.
|
|
165
|
-
grant_scope: grantScope,
|
|
166
|
-
// If the environment variable CONFORMITY_FAKE_CLAIMS is set we are assuming that
|
|
167
|
-
// the app is built for the automated OpenID Connect Conformity Test Suite. You
|
|
168
|
-
// can peak inside the code for some ideas, but be aware that all data is fake
|
|
169
|
-
// and this only exists to fake a login system which works in accordance to OpenID Connect.
|
|
170
|
-
//
|
|
171
|
-
// If that variable is not set, the session will be used as-is.
|
|
172
|
-
session: (0, oidc_cert_1.oidcConformityMaybeFakeSession)(grantScope, body, session),
|
|
173
|
-
// ORY Hydra checks if requested audiences are allowed by the client, so we can simply echo this.
|
|
174
|
-
grant_access_token_audience: body.requested_access_token_audience,
|
|
175
|
-
// This tells hydra to remember this consent request and allow the same client to request the same
|
|
176
|
-
// scopes from the same user, without showing the UI, in the future.
|
|
177
|
-
remember: Boolean(req.body.remember),
|
|
178
|
-
// When this "remember" sesion expires, in seconds. Set this to 0 so it will never expire.
|
|
179
|
-
remember_for: 3600
|
|
180
|
-
})
|
|
181
|
-
.then(function (_a) {
|
|
182
|
-
var body = _a.data;
|
|
183
|
-
// All we need to do now is to redirect the user back to hydra!
|
|
184
|
-
res.redirect(String(body.redirect_to));
|
|
185
|
-
});
|
|
186
|
-
})
|
|
187
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
188
|
-
.catch(next);
|
|
189
|
-
// label:docs-accept-consent
|
|
190
|
-
});
|
|
191
|
-
exports.default = router;
|
|
192
|
-
//# sourceMappingURL=consent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consent.js","sourceRoot":"","sources":["../../src/oauth2/consent.ts"],"names":[],"mappings":";;AAAA,iCAAkC;AAClC,yBAA0B;AAC1B,mCAAqC;AACrC,8CAAiE;AAEjE,IAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9B,IAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,0BAA0B;AAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7C,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;AAG/B,IAAM,eAAe,GAAG,UAAC,IAAI,EAAE,UAAU;IACvC,qEAAqE;IACrE,IAAI,OAAO,GAA0B;QACnC,qGAAqG;QACrG,8CAA8C;QAC9C,YAAY,EAAE;QACZ,aAAa;SACd;QAED,+CAA+C;QAC/C,QAAQ,EAAE;QACR,aAAa;SACd;KACF,CAAA;IACD,IAAI,WAAW,GAAG,UAAU,CAAA;IAC5B,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QAC3B,WAAW,GAAG,CAAC,WAAW,CAAC,CAAC;KAC7B;IACD,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAC,KAAK;QACxB,IAAI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AAC,UAAC,EAAc;gBAAN,IAAI,UAAA;YACjB,+DAA+D;YAC/D,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;QACxC,CAAC,CAAC,CAAA;IACN,CAAC,CAAC;QACF,0EAA0E;SACzE,KAAK,CAAC,IAAI,CAAC,CAAA;IACd,4BAA4B;AAC9B,CAAC,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
|
package/lib/oauth2/login.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var express = require("express");
|
|
4
|
-
var url = require("url");
|
|
5
|
-
var config_1 = require("./config");
|
|
6
|
-
var oidc_cert_1 = require("./stub/oidc-cert");
|
|
7
|
-
var csrf = require('csurf');
|
|
8
|
-
var urljoin = require('url-join');
|
|
9
|
-
// Sets up csrf protection
|
|
10
|
-
var csrfProtection = csrf({ cookie: true });
|
|
11
|
-
var router = express.Router();
|
|
12
|
-
router.get('/', csrfProtection, function (req, res, next) {
|
|
13
|
-
// Parses the URL query
|
|
14
|
-
var query = url.parse(req.url, true).query;
|
|
15
|
-
// The challenge is used to fetch information about the login request from ORY Hydra.
|
|
16
|
-
var challenge = String(query.login_challenge);
|
|
17
|
-
if (!challenge) {
|
|
18
|
-
next(new Error('Expected a login challenge to be set but received none.'));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
config_1.hydraAdmin.getLoginRequest(challenge)
|
|
22
|
-
.then(function (_a) {
|
|
23
|
-
var body = _a.data;
|
|
24
|
-
// If hydra was already able to authenticate the user, skip will be true and we do not need to re-authenticate
|
|
25
|
-
// the user.
|
|
26
|
-
if (body.skip) {
|
|
27
|
-
// You can apply logic here, for example update the number of times the user logged in.
|
|
28
|
-
// ...
|
|
29
|
-
// Now it's time to grant the login request. You could also deny the request if something went terribly wrong
|
|
30
|
-
// (e.g. your arch-enemy logging in...)
|
|
31
|
-
return config_1.hydraAdmin
|
|
32
|
-
.acceptLoginRequest(challenge, {
|
|
33
|
-
// All we need to do is to confirm that we indeed want to log in the user.
|
|
34
|
-
subject: String(body.subject)
|
|
35
|
-
})
|
|
36
|
-
.then(function (_a) {
|
|
37
|
-
var body = _a.data;
|
|
38
|
-
// All we need to do now is to redirect the user back to hydra!
|
|
39
|
-
res.redirect(String(body.redirect_to));
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
// If authentication can't be skipped we MUST show the login UI.
|
|
43
|
-
// return res.json({
|
|
44
|
-
// csrfToken: (req as any).csrfToken(),
|
|
45
|
-
// challenge: challenge,
|
|
46
|
-
// action: urljoin(process.env.BASE_URL || '', '/login'),
|
|
47
|
-
// hint: body.oidc_context?.login_hint || ''
|
|
48
|
-
// })
|
|
49
|
-
var user = req.user;
|
|
50
|
-
if (user) {
|
|
51
|
-
config_1.hydraAdmin
|
|
52
|
-
.acceptLoginRequest(challenge, {
|
|
53
|
-
// Subject is an alias for user ID. A subject can be a random string, a UUID, an email address, ....
|
|
54
|
-
subject: user.userId,
|
|
55
|
-
// This tells hydra to remember the browser and automatically authenticate the user in future requests. This will
|
|
56
|
-
// set the "skip" parameter in the other route to true on subsequent requests!
|
|
57
|
-
remember: Boolean(req.body.remember),
|
|
58
|
-
// When the session expires, in seconds. Set this to 0 so it will never expire.
|
|
59
|
-
remember_for: 3600,
|
|
60
|
-
// Sets which "level" (e.g. 2-factor authentication) of authentication the user has. The value is really arbitrary
|
|
61
|
-
// and optional. In the context of OpenID Connect, a value of 0 indicates the lowest authorization level.
|
|
62
|
-
// acr: '0',
|
|
63
|
-
//
|
|
64
|
-
// If the environment variable CONFORMITY_FAKE_CLAIMS is set we are assuming that
|
|
65
|
-
// the app is built for the automated OpenID Connect Conformity Test Suite. You
|
|
66
|
-
// can peak inside the code for some ideas, but be aware that all data is fake
|
|
67
|
-
// and this only exists to fake a login system which works in accordance to OpenID Connect.
|
|
68
|
-
//
|
|
69
|
-
// If that variable is not set, the ACR value will be set to the default passed here ('0')
|
|
70
|
-
acr: (0, oidc_cert_1.oidcConformityMaybeFakeAcr)(body, '0')
|
|
71
|
-
})
|
|
72
|
-
.then(function (_a) {
|
|
73
|
-
var body = _a.data;
|
|
74
|
-
// All we need to do now is to redirect the user back to hydra!
|
|
75
|
-
res.redirect(String(body.redirect_to));
|
|
76
|
-
}).catch(function (error) {
|
|
77
|
-
console.log("oauth2 login acceptLoginRequest error", error.message);
|
|
78
|
-
next();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
res.redirect("/accounts/a/#/login?redirect_uri=" + encodeURIComponent(Meteor.absoluteUrl("/oauth2/login?login_challenge=".concat(challenge))));
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
86
|
-
.catch(function (error) {
|
|
87
|
-
console.log("oauth2 login error", error.message);
|
|
88
|
-
next();
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
// router.post('/', csrfProtection, (req, res, next) => {
|
|
92
|
-
// // The challenge is now a hidden input field, so let's take it from the request body instead
|
|
93
|
-
// const challenge = req.body.challenge
|
|
94
|
-
// // Let's see if the user decided to accept or reject the consent request..
|
|
95
|
-
// if (req.body.submit === 'Deny access') {
|
|
96
|
-
// // Looks like the consent request was denied by the user
|
|
97
|
-
// return (
|
|
98
|
-
// hydraAdmin
|
|
99
|
-
// .rejectLoginRequest(challenge, {
|
|
100
|
-
// error: 'access_denied',
|
|
101
|
-
// error_description: 'The resource owner denied the request'
|
|
102
|
-
// })
|
|
103
|
-
// .then(({ data: body }) => {
|
|
104
|
-
// // All we need to do now is to redirect the browser back to hydra!
|
|
105
|
-
// res.redirect(String(body.redirect_to))
|
|
106
|
-
// })
|
|
107
|
-
// // This will handle any error that happens when making HTTP calls to hydra
|
|
108
|
-
// .catch(next)
|
|
109
|
-
// )
|
|
110
|
-
// }
|
|
111
|
-
// // Let's check if the user provided valid credentials. Of course, you'd use a database or some third-party service
|
|
112
|
-
// // for this!
|
|
113
|
-
// if (!(req.body.email === 'foo@bar.com' && req.body.password === 'foobar')) {
|
|
114
|
-
// // Looks like the user provided invalid credentials, let's show the ui again...
|
|
115
|
-
// return res.json({
|
|
116
|
-
// csrfToken: (req as any).csrfToken(),
|
|
117
|
-
// challenge: challenge,
|
|
118
|
-
// error: 'The username / password combination is not correct'
|
|
119
|
-
// });
|
|
120
|
-
// }
|
|
121
|
-
// // Seems like the user authenticated! Let's tell hydra...
|
|
122
|
-
// hydraAdmin
|
|
123
|
-
// .getLoginRequest(challenge)
|
|
124
|
-
// .then(({ data: loginRequest }) =>
|
|
125
|
-
// hydraAdmin
|
|
126
|
-
// .acceptLoginRequest(challenge, {
|
|
127
|
-
// // Subject is an alias for user ID. A subject can be a random string, a UUID, an email address, ....
|
|
128
|
-
// subject: 'foo@bar.com',
|
|
129
|
-
// // This tells hydra to remember the browser and automatically authenticate the user in future requests. This will
|
|
130
|
-
// // set the "skip" parameter in the other route to true on subsequent requests!
|
|
131
|
-
// remember: Boolean(req.body.remember),
|
|
132
|
-
// // When the session expires, in seconds. Set this to 0 so it will never expire.
|
|
133
|
-
// remember_for: 3600,
|
|
134
|
-
// // Sets which "level" (e.g. 2-factor authentication) of authentication the user has. The value is really arbitrary
|
|
135
|
-
// // and optional. In the context of OpenID Connect, a value of 0 indicates the lowest authorization level.
|
|
136
|
-
// // acr: '0',
|
|
137
|
-
// //
|
|
138
|
-
// // If the environment variable CONFORMITY_FAKE_CLAIMS is set we are assuming that
|
|
139
|
-
// // the app is built for the automated OpenID Connect Conformity Test Suite. You
|
|
140
|
-
// // can peak inside the code for some ideas, but be aware that all data is fake
|
|
141
|
-
// // and this only exists to fake a login system which works in accordance to OpenID Connect.
|
|
142
|
-
// //
|
|
143
|
-
// // If that variable is not set, the ACR value will be set to the default passed here ('0')
|
|
144
|
-
// acr: oidcConformityMaybeFakeAcr(loginRequest, '0')
|
|
145
|
-
// })
|
|
146
|
-
// .then(({ data: body }) => {
|
|
147
|
-
// // All we need to do now is to redirect the user back to hydra!
|
|
148
|
-
// res.redirect(String(body.redirect_to))
|
|
149
|
-
// })
|
|
150
|
-
// )
|
|
151
|
-
// // This will handle any error that happens when making HTTP calls to hydra
|
|
152
|
-
// .catch(next)
|
|
153
|
-
// // You could also deny the login request which tells hydra that no one authenticated!
|
|
154
|
-
// // hydra.rejectLoginRequest(challenge, {
|
|
155
|
-
// // error: 'invalid_request',
|
|
156
|
-
// // errorDescription: 'The user did something stupid...'
|
|
157
|
-
// // })
|
|
158
|
-
// // .then(({body}) => {
|
|
159
|
-
// // // All we need to do now is to redirect the browser back to hydra!
|
|
160
|
-
// // res.redirect(String(body.redirectTo));
|
|
161
|
-
// // })
|
|
162
|
-
// // // This will handle any error that happens when making HTTP calls to hydra
|
|
163
|
-
// // .catch(next);
|
|
164
|
-
// })
|
|
165
|
-
exports.default = router;
|
|
166
|
-
//# sourceMappingURL=login.js.map
|
package/lib/oauth2/login.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/oauth2/login.ts"],"names":[],"mappings":";;AAAA,iCAAkC;AAClC,yBAA0B;AAC1B,mCAAqC;AACrC,8CAA6D;AAC7D,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9B,IAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,0BAA0B;AAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7C,IAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;AAI/B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,UAAC,GAAG,EAAE,GAAG,EAAE,IAAI;IAC3C,uBAAuB;IACvB,IAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAA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0EAA0E;AAC1E,cAAc;AACd,QAAQ;AAER,gEAAgE;AAEhE,iBAAiB;AACjB,sCAAsC;AACtC,4CAA4C;AAC5C,yBAAyB;AACzB,mDAAmD;AACnD,2HAA2H;AAC3H,8CAA8C;AAE9C,wIAAwI;AACxI,qGAAqG;AACrG,4DAA4D;AAE5D,sGAAsG;AACtG,0CAA0C;AAE1C,yIAAyI;AACzI,gIAAgI;AAChI,mCAAmC;AACnC,yBAAyB;AACzB,wGAAwG;AACxG,sGAAsG;AACtG,qGAAqG;AACrG,kHAAkH;AAClH,yBAAyB;AACzB,iHAAiH;AACjH,yEAAyE;AACzE,qBAAqB;AACrB,8CAA8C;AAC9C,sFAAsF;AACtF,6DAA6D;AAC7D,qBAAqB;AACrB,YAAY;AACZ,qFAAqF;AACrF,uBAAuB;AAEvB,4FAA4F;AAC5F,+CAA+C;AAC/C,qCAAqC;AACrC,gEAAgE;AAChE,YAAY;AACZ,+BAA+B;AAC/B,gFAAgF;AAChF,oDAAoD;AACpD,cAAc;AACd,sFAAsF;AACtF,yBAAyB;AACzB,KAAK;AAEL,kBAAe,MAAM,CAAA"}
|
package/lib/oauth2/logout.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var express = require("express");
|
|
4
|
-
var url = require("url");
|
|
5
|
-
var config_1 = require("./config");
|
|
6
|
-
var csrf = require('csurf');
|
|
7
|
-
var urljoin = require('url-join');
|
|
8
|
-
// Sets up csrf protection
|
|
9
|
-
var csrfProtection = csrf({ cookie: true });
|
|
10
|
-
var router = express.Router();
|
|
11
|
-
router.get('/', csrfProtection, function (req, res, next) {
|
|
12
|
-
// Parses the URL query
|
|
13
|
-
var query = url.parse(req.url, true).query;
|
|
14
|
-
// The challenge is used to fetch information about the logout request from ORY Hydra.
|
|
15
|
-
var challenge = String(query.logout_challenge);
|
|
16
|
-
if (!challenge) {
|
|
17
|
-
next(new Error('Expected a logout challenge to be set but received none.'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
config_1.hydraAdmin
|
|
21
|
-
.getLogoutRequest(challenge)
|
|
22
|
-
// This will be called if the HTTP request was successful
|
|
23
|
-
.then(function () {
|
|
24
|
-
// Here we have access to e.g. response.subject, response.sid, ...
|
|
25
|
-
// The most secure way to perform a logout request is by asking the user if he/she really want to log out.
|
|
26
|
-
return res.status(200).send({
|
|
27
|
-
csrfToken: req.csrfToken(),
|
|
28
|
-
challenge: challenge,
|
|
29
|
-
action: urljoin(process.env.BASE_URL || '', '/logout')
|
|
30
|
-
});
|
|
31
|
-
})
|
|
32
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
33
|
-
.catch(next);
|
|
34
|
-
});
|
|
35
|
-
router.post('/', csrfProtection, function (req, res, next) {
|
|
36
|
-
// The challenge is now a hidden input field, so let's take it from the request body instead
|
|
37
|
-
var challenge = req.body.challenge;
|
|
38
|
-
if (req.body.submit === 'No') {
|
|
39
|
-
return (config_1.hydraAdmin
|
|
40
|
-
.rejectLogoutRequest(challenge)
|
|
41
|
-
.then(function () {
|
|
42
|
-
// The user did not want to log out. Let's redirect him back somewhere or do something else.
|
|
43
|
-
res.redirect('https://www.ory.sh/');
|
|
44
|
-
})
|
|
45
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
46
|
-
.catch(next));
|
|
47
|
-
}
|
|
48
|
-
// The user agreed to log out, let's accept the logout request.
|
|
49
|
-
config_1.hydraAdmin
|
|
50
|
-
.acceptLogoutRequest(challenge)
|
|
51
|
-
.then(function (_a) {
|
|
52
|
-
var body = _a.data;
|
|
53
|
-
// All we need to do now is to redirect the user back to hydra!
|
|
54
|
-
res.redirect(String(body.redirect_to));
|
|
55
|
-
})
|
|
56
|
-
// This will handle any error that happens when making HTTP calls to hydra
|
|
57
|
-
.catch(next);
|
|
58
|
-
});
|
|
59
|
-
exports.default = router;
|
|
60
|
-
//# sourceMappingURL=logout.js.map
|
package/lib/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,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,UAAC,GAAG,EAAE,GAAG,EAAE,IAAI;IAC9C,4FAA4F;IAC5F,IAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAA;IAEpC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;QAC5B,OAAO,CACL,mBAAU;aACP,mBAAmB,CAAC,SAAS,CAAC;aAC9B,IAAI,CAAC;YACJ,4FAA4F;YAC5F,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAA;QACrC,CAAC,CAAC;YACF,0EAA0E;aACzE,KAAK,CAAC,IAAI,CAAC,CACf,CAAA;KACF;IAED,+DAA+D;IAC/D,mBAAU;SACP,mBAAmB,CAAC,SAAS,CAAC;SAC9B,IAAI,CAAC,UAAC,EAAc;YAAN,IAAI,UAAA;QACjB,+DAA+D;QAC/D,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC;QACF,0EAA0E;SACzE,KAAK,CAAC,IAAI,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file contains logic which is used when running this application as part of the
|
|
3
|
-
// OpenID Connect Conformance test suite. You can use it for inspiration, but please
|
|
4
|
-
// do not use it in production as is.
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.oidcConformityMaybeFakeSession = exports.oidcConformityMaybeFakeAcr = void 0;
|
|
7
|
-
var tslib_1 = require("tslib");
|
|
8
|
-
var oidcConformityMaybeFakeAcr = function (request, fallback) {
|
|
9
|
-
var _a;
|
|
10
|
-
if (process.env.CONFORMITY_FAKE_CLAIMS !== '1') {
|
|
11
|
-
return fallback;
|
|
12
|
-
}
|
|
13
|
-
return ((_a = request.oidc_context) === null || _a === void 0 ? void 0 : _a.acr_values) &&
|
|
14
|
-
request.oidc_context.acr_values.length > 0
|
|
15
|
-
? request.oidc_context.acr_values[request.oidc_context.acr_values.length - 1]
|
|
16
|
-
: fallback;
|
|
17
|
-
};
|
|
18
|
-
exports.oidcConformityMaybeFakeAcr = oidcConformityMaybeFakeAcr;
|
|
19
|
-
var oidcConformityMaybeFakeSession = function (grantScope, request, session) {
|
|
20
|
-
if (process.env.CONFORMITY_FAKE_CLAIMS !== '1') {
|
|
21
|
-
return session;
|
|
22
|
-
}
|
|
23
|
-
var idToken = {};
|
|
24
|
-
// If the email scope was granted, fake the email claims.
|
|
25
|
-
if (grantScope.indexOf('email') > -1) {
|
|
26
|
-
// But only do so if the email was requested!
|
|
27
|
-
idToken.email = 'foo@bar.com';
|
|
28
|
-
idToken.email_verified = true;
|
|
29
|
-
}
|
|
30
|
-
// If the phone scope was granted, fake the phone claims.
|
|
31
|
-
if (grantScope.indexOf('phone') > -1) {
|
|
32
|
-
idToken.phone_number = '1337133713371337';
|
|
33
|
-
idToken.phone_number_verified = true;
|
|
34
|
-
}
|
|
35
|
-
// If the profile scope was granted, fake the profile claims.
|
|
36
|
-
if (grantScope.indexOf('profile') > -1) {
|
|
37
|
-
idToken.name = 'Foo Bar';
|
|
38
|
-
idToken.given_name = 'Foo';
|
|
39
|
-
idToken.family_name = 'Bar';
|
|
40
|
-
idToken.website = 'https://www.ory.sh';
|
|
41
|
-
idToken.zoneinfo = 'Europe/Belrin';
|
|
42
|
-
idToken.birthdate = '1.1.2014';
|
|
43
|
-
idToken.gender = 'robot';
|
|
44
|
-
idToken.profile = 'https://www.ory.sh';
|
|
45
|
-
idToken.preferred_username = 'robot';
|
|
46
|
-
idToken.middle_name = 'Baz';
|
|
47
|
-
idToken.locale = 'en-US';
|
|
48
|
-
idToken.picture =
|
|
49
|
-
'https://raw.githubusercontent.com/ory/web/master/static/images/favico.png';
|
|
50
|
-
idToken.updated_at = 1604416603;
|
|
51
|
-
idToken.nickname = 'foobot';
|
|
52
|
-
}
|
|
53
|
-
// If the address scope was granted, fake the address claims.
|
|
54
|
-
if (grantScope.indexOf('address') > -1) {
|
|
55
|
-
idToken.address = {
|
|
56
|
-
country: 'Localhost',
|
|
57
|
-
region: 'Intranet',
|
|
58
|
-
street_address: 'Local Street 1337'
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
access_token: session.access_token,
|
|
63
|
-
id_token: tslib_1.__assign(tslib_1.__assign({}, idToken), session.id_token)
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
exports.oidcConformityMaybeFakeSession = oidcConformityMaybeFakeSession;
|
|
67
|
-
//# sourceMappingURL=oidc-cert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-cert.js","sourceRoot":"","sources":["../../../src/oauth2/stub/oidc-cert.ts"],"names":[],"mappings":";AAAA,sFAAsF;AACtF,oFAAoF;AACpF,qCAAqC;;;;AAQ9B,IAAM,0BAA0B,GAAG,UACxC,OAAqB,EACrB,QAAgB;;IAEhB,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,GAAG,EAAE;QAC9C,OAAO,QAAQ,CAAA;KAChB;IAED,OAAO,CAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,UAAU;QACrC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAC1C,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAC7B,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAC3C;QACH,CAAC,CAAC,QAAQ,CAAA;AACd,CAAC,CAAA;AAdY,QAAA,0BAA0B,8BActC;AAEM,IAAM,8BAA8B,GAAG,UAC5C,UAAoB,EACpB,OAAuB,EACvB,OAA8B;IAE9B,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,G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