Merge pull request #9408 from backstage/freben/node-common-again

Add the `@backstage/plugin-auth-node` package
This commit is contained in:
Fredrik Adelöw
2022-02-10 11:08:32 +01:00
committed by GitHub
38 changed files with 500 additions and 237 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-auth-node': minor
---
Added this package, to hold shared types and functionality that other backend
packages need to import.
+51
View File
@@ -0,0 +1,51 @@
---
'@backstage/plugin-auth-backend': minor
---
The following breaking changes were made, which may imply specifically needing
to make small adjustments in your custom auth providers.
- **BREAKING**: Moved `IdentityClient`, `BackstageSignInResult`,
`BackstageIdentityResponse`, and `BackstageUserIdentity` to
`@backstage/plugin-auth-node`.
- **BREAKING**: Removed deprecated type `BackstageIdentity`, please use
`BackstageSignInResult` from `@backstage/plugin-auth-node` instead.
While moving over, `IdentityClient` was also changed in the following ways:
- **BREAKING**: Made `IdentityClient.listPublicKeys` private. It was only used
in tests, and should not be part of the API surface of that class.
- **BREAKING**: Removed the static `IdentityClient.getBearerToken`. It is now
replaced by `getBearerTokenFromAuthorizationHeader` from
`@backstage/plugin-auth-node`.
- **BREAKING**: Removed the constructor. Please use the `IdentityClient.create`
static method instead.
Since the `IdentityClient` interface is marked as experimental, this is a
breaking change without a deprecation period.
In your auth providers, you may need to update your imports and usages as
follows (example code; yours may be slightly different):
````diff
-import { IdentityClient } from '@backstage/plugin-auth-backend';
+import {
+ IdentityClient,
+ getBearerTokenFromAuthorizationHeader
+} from '@backstage/plugin-auth-node';
// ...
- const identity = new IdentityClient({
+ const identity = IdentityClient.create({
discovery,
issuer: await discovery.getExternalBaseUrl('auth'),
});```
// ...
const token =
- IdentityClient.getBearerToken(req.headers.authorization) ||
+ getBearerTokenFromAuthorizationHeader(req.headers.authorization) ||
req.cookies['token'];
````
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-permission-backend': patch
'@backstage/plugin-search-backend': patch
---
Use `getBearerTokenFromAuthorizationHeader` from `@backstage/plugin-auth-node` instead of the deprecated `IdentityClient` method.