@backstage/plugin-auth-backend 0.4.8 → 0.4.9
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/CHANGELOG.md +24 -0
- package/README.md +6 -6
- package/dist/index.cjs.js +19 -25
- package/dist/index.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend
|
|
2
2
|
|
|
3
|
+
## 0.4.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9312572360: Switched to using the standardized JSON error responses for all provider endpoints.
|
|
8
|
+
- bab752e2b3: Change default port of backend from 7000 to 7007.
|
|
9
|
+
|
|
10
|
+
This is due to the AirPlay Receiver process occupying port 7000 and preventing local Backstage instances on MacOS to start.
|
|
11
|
+
|
|
12
|
+
You can change the port back to 7000 or any other value by providing an `app-config.yaml` with the following values:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
backend:
|
|
16
|
+
listen: 0.0.0.0:7123
|
|
17
|
+
baseUrl: http://localhost:7123
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
More information can be found here: https://backstage.io/docs/conf/writing
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @backstage/errors@0.1.5
|
|
24
|
+
- @backstage/backend-common@0.9.11
|
|
25
|
+
- @backstage/test-utils@0.1.23
|
|
26
|
+
|
|
3
27
|
## 0.4.8
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Follow this link, [Create new OAuth App](https://github.com/settings/application
|
|
|
34
34
|
1. Set Application Name to `backstage-dev` or something along those lines.
|
|
35
35
|
1. You can set the Homepage URL to whatever you want to.
|
|
36
36
|
1. The Authorization Callback URL should match the redirect URI set in Backstage.
|
|
37
|
-
1. Set this to `http://localhost:
|
|
37
|
+
1. Set this to `http://localhost:7007/api/auth/github` for local development.
|
|
38
38
|
1. Set this to `http://{APP_FQDN}:{APP_BACKEND_PORT}/api/auth/github` for non-local deployments.
|
|
39
39
|
|
|
40
40
|
```bash
|
|
@@ -58,7 +58,7 @@ Follow this link, [Add new application](https://gitlab.com/-/profile/application
|
|
|
58
58
|
|
|
59
59
|
1. Set Application Name to `backstage-dev` or something along those lines.
|
|
60
60
|
1. The Authorization Callback URL should match the redirect URI set in Backstage.
|
|
61
|
-
1. Set this to `http://localhost:
|
|
61
|
+
1. Set this to `http://localhost:7007/api/auth/gitlab/handler/frame` for local development.
|
|
62
62
|
1. Set this to `http://{APP_FQDN}:{APP_BACKEND_PORT}/api/auth/gitlab/handler/frame` for non-local deployments.
|
|
63
63
|
1. Select the following scopes from the list:
|
|
64
64
|
- [x] `read_user` Grants read-only access to the authenticated user's profile through the /user API endpoint, which includes username, public email, and full name. Also grants access to read-only API endpoints under /users.
|
|
@@ -91,9 +91,9 @@ export AUTH_GITLAB_CLIENT_SECRET=x
|
|
|
91
91
|
|
|
92
92
|
Add a new Okta application using the following URI conventions:
|
|
93
93
|
|
|
94
|
-
Login redirect URI's: `http://localhost:
|
|
95
|
-
Logout redirect URI's: `http://localhost:
|
|
96
|
-
Initiate login URI's: `http://localhost:
|
|
94
|
+
Login redirect URI's: `http://localhost:7007/api/auth/okta/handler/frame`
|
|
95
|
+
Logout redirect URI's: `http://localhost:7007/api/auth/okta/logout`
|
|
96
|
+
Initiate login URI's: `http://localhost:7007/api/auth/okta/start`
|
|
97
97
|
|
|
98
98
|
Then configure the following environment variables to be used in the `app-config.yaml` file:
|
|
99
99
|
|
|
@@ -122,7 +122,7 @@ Click [here](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMe
|
|
|
122
122
|
- Give the app a name. e.g. `backstage-dev`
|
|
123
123
|
- Select `Accounts in this organizational directory only` under supported account types.
|
|
124
124
|
- Enter the callback URL for your backstage backend instance:
|
|
125
|
-
- For local development, this is likely `http://localhost:
|
|
125
|
+
- For local development, this is likely `http://localhost:7007/api/auth/microsoft/handler/frame`
|
|
126
126
|
- For non-local deployments, this will be `https://{APP_FQDN}:{APP_BACKEND_PORT}/auth/microsoft/handler/frame`
|
|
127
127
|
- Click `Register`.
|
|
128
128
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -227,22 +227,22 @@ class OAuthEnvironmentHandler {
|
|
|
227
227
|
return new OAuthEnvironmentHandler(handlers);
|
|
228
228
|
}
|
|
229
229
|
async start(req, res) {
|
|
230
|
-
const provider = this.getProviderForEnv(req
|
|
231
|
-
await
|
|
230
|
+
const provider = this.getProviderForEnv(req);
|
|
231
|
+
await provider.start(req, res);
|
|
232
232
|
}
|
|
233
233
|
async frameHandler(req, res) {
|
|
234
|
-
const provider = this.getProviderForEnv(req
|
|
235
|
-
await
|
|
234
|
+
const provider = this.getProviderForEnv(req);
|
|
235
|
+
await provider.frameHandler(req, res);
|
|
236
236
|
}
|
|
237
237
|
async refresh(req, res) {
|
|
238
238
|
var _a;
|
|
239
|
-
const provider = this.getProviderForEnv(req
|
|
240
|
-
await ((_a = provider
|
|
239
|
+
const provider = this.getProviderForEnv(req);
|
|
240
|
+
await ((_a = provider.refresh) == null ? void 0 : _a.call(provider, req, res));
|
|
241
241
|
}
|
|
242
242
|
async logout(req, res) {
|
|
243
243
|
var _a;
|
|
244
|
-
const provider = this.getProviderForEnv(req
|
|
245
|
-
await ((_a = provider
|
|
244
|
+
const provider = this.getProviderForEnv(req);
|
|
245
|
+
await ((_a = provider.logout) == null ? void 0 : _a.call(provider, req, res));
|
|
246
246
|
}
|
|
247
247
|
getRequestFromEnv(req) {
|
|
248
248
|
var _a, _b;
|
|
@@ -257,19 +257,16 @@ class OAuthEnvironmentHandler {
|
|
|
257
257
|
const env = readState(stateParams).env;
|
|
258
258
|
return env;
|
|
259
259
|
}
|
|
260
|
-
getProviderForEnv(req
|
|
260
|
+
getProviderForEnv(req) {
|
|
261
261
|
const env = this.getRequestFromEnv(req);
|
|
262
262
|
if (!env) {
|
|
263
263
|
throw new errors.InputError(`Must specify 'env' query to select environment`);
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
<br>
|
|
269
|
-
For this flow to work you need to supply a valid configuration for the "${env}" environment of provider.`);
|
|
270
|
-
return void 0;
|
|
265
|
+
const handler = this.handlers.get(env);
|
|
266
|
+
if (!handler) {
|
|
267
|
+
throw new errors.NotFoundError(`No configuration available for the '${env}' environment of this provider.`);
|
|
271
268
|
}
|
|
272
|
-
return
|
|
269
|
+
return handler;
|
|
273
270
|
}
|
|
274
271
|
}
|
|
275
272
|
|
|
@@ -428,26 +425,23 @@ class OAuthAdapter {
|
|
|
428
425
|
}
|
|
429
426
|
async logout(req, res) {
|
|
430
427
|
if (!ensuresXRequestedWith(req)) {
|
|
431
|
-
|
|
432
|
-
return;
|
|
428
|
+
throw new errors.AuthenticationError("Invalid X-Requested-With header");
|
|
433
429
|
}
|
|
434
430
|
this.removeRefreshTokenCookie(res);
|
|
435
|
-
res.status(200).
|
|
431
|
+
res.status(200).end();
|
|
436
432
|
}
|
|
437
433
|
async refresh(req, res) {
|
|
438
434
|
var _a, _b;
|
|
439
435
|
if (!ensuresXRequestedWith(req)) {
|
|
440
|
-
|
|
441
|
-
return;
|
|
436
|
+
throw new errors.AuthenticationError("Invalid X-Requested-With header");
|
|
442
437
|
}
|
|
443
438
|
if (!this.handlers.refresh || this.options.disableRefresh) {
|
|
444
|
-
|
|
445
|
-
return;
|
|
439
|
+
throw new errors.InputError(`Refresh token is not supported for provider ${this.options.providerId}`);
|
|
446
440
|
}
|
|
447
441
|
try {
|
|
448
442
|
const refreshToken = req.cookies[`${this.options.providerId}-refresh-token`];
|
|
449
443
|
if (!refreshToken) {
|
|
450
|
-
throw new
|
|
444
|
+
throw new errors.InputError("Missing session cookie");
|
|
451
445
|
}
|
|
452
446
|
const scope = (_b = (_a = req.query.scope) == null ? void 0 : _a.toString()) != null ? _b : "";
|
|
453
447
|
const forwardReq = Object.assign(req, {scope, refreshToken});
|
|
@@ -458,7 +452,7 @@ class OAuthAdapter {
|
|
|
458
452
|
}
|
|
459
453
|
res.status(200).json(response);
|
|
460
454
|
} catch (error) {
|
|
461
|
-
|
|
455
|
+
throw new errors.AuthenticationError("Refresh failed", error);
|
|
462
456
|
}
|
|
463
457
|
}
|
|
464
458
|
async populateIdentity(identity) {
|