@backstage/plugin-auth-backend 0.13.1-next.0 → 0.13.1-next.1

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.13.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cac3ba68a2: Fixed a bug that was introduced in `0.13.1-next.0` which caused the `ent` claim of issued tokens to be dropped.
8
+ - 5d268623dd: Updates the OAuth2 Proxy provider to require less infrastructure configuration.
9
+
10
+ The auth result object of the OAuth2 Proxy now provides access to the request headers, both through the `headers` object as well as `getHeader` method. The existing logic that parses and extracts the user information from ID tokens is deprecated and will be removed in a future release. See the OAuth2 Proxy provider documentation for more details.
11
+
12
+ The OAuth2 Proxy provider now also has a default `authHandler` implementation that reads the display name and email from the incoming request headers.
13
+
14
+ - Updated dependencies
15
+ - @backstage/backend-common@0.13.3-next.1
16
+
3
17
  ## 0.13.1-next.0
4
18
 
5
19
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1641,7 +1641,20 @@ class Oauth2ProxyAuthProvider {
1641
1641
  }
1642
1642
  async refresh(req, res) {
1643
1643
  try {
1644
- const result = this.getResult(req);
1644
+ const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);
1645
+ const jwt = pluginAuthNode.getBearerTokenFromAuthorizationHeader(authHeader);
1646
+ const decodedJWT = jwt && jose.decodeJwt(jwt);
1647
+ const result = {
1648
+ fullProfile: decodedJWT || {},
1649
+ accessToken: jwt || "",
1650
+ headers: req.headers,
1651
+ getHeader(name) {
1652
+ if (name.toLocaleLowerCase("en-US") === "set-cookie") {
1653
+ throw new Error("Access Set-Cookie via the headers object instead");
1654
+ }
1655
+ return req.get(name);
1656
+ }
1657
+ };
1645
1658
  const response = await this.handleResult(result);
1646
1659
  res.json(response);
1647
1660
  } catch (e) {
@@ -1665,18 +1678,14 @@ class Oauth2ProxyAuthProvider {
1665
1678
  profile
1666
1679
  };
1667
1680
  }
1668
- getResult(req) {
1669
- const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);
1670
- const jwt = pluginAuthNode.getBearerTokenFromAuthorizationHeader(authHeader);
1671
- if (!jwt) {
1672
- throw new errors.AuthenticationError(`Missing or in incorrect format - Oauth2Proxy OIDC header: ${OAUTH2_PROXY_JWT_HEADER}`);
1681
+ }
1682
+ async function defaultAuthHandler$1(result) {
1683
+ return {
1684
+ profile: {
1685
+ email: result.getHeader("x-forwarded-email"),
1686
+ displayName: result.getHeader("x-forwarded-preferred-username") || result.getHeader("x-forwarded-user")
1673
1687
  }
1674
- const decodedJWT = jose.decodeJwt(jwt);
1675
- return {
1676
- fullProfile: decodedJWT,
1677
- accessToken: jwt
1678
- };
1679
- }
1688
+ };
1680
1689
  }
1681
1690
  const oauth2Proxy = createAuthProviderIntegration({
1682
1691
  create(options) {
@@ -1686,7 +1695,7 @@ const oauth2Proxy = createAuthProviderIntegration({
1686
1695
  return new Oauth2ProxyAuthProvider({
1687
1696
  resolverContext,
1688
1697
  signInResolver,
1689
- authHandler
1698
+ authHandler: authHandler != null ? authHandler : defaultAuthHandler$1
1690
1699
  });
1691
1700
  };
1692
1701
  }
@@ -2316,7 +2325,7 @@ class TokenFactory {
2316
2325
  if (!key.alg) {
2317
2326
  throw new errors.AuthenticationError("No algorithm was provided in the key");
2318
2327
  }
2319
- return new jose.SignJWT({ iss, sub, aud, iat, exp }).setProtectedHeader({ alg: key.alg, kid: key.kid }).setIssuer(iss).setAudience(aud).setSubject(sub).setIssuedAt(iat).setExpirationTime(exp).sign(await jose.importJWK(key));
2328
+ return new jose.SignJWT({ iss, sub, ent, aud, iat, exp }).setProtectedHeader({ alg: key.alg, kid: key.kid }).setIssuer(iss).setAudience(aud).setSubject(sub).setIssuedAt(iat).setExpirationTime(exp).sign(await jose.importJWK(key));
2320
2329
  }
2321
2330
  async listPublicKeys() {
2322
2331
  const { items: keys } = await this.keyStore.listKeys();