Skip to content

Commit

Permalink
move away from deprecated types, import from auth-node
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Feb 16, 2024
1 parent a5e494c commit f5e04e3
Show file tree
Hide file tree
Showing 37 changed files with 166 additions and 133 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-frogs-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-auth-backend': patch
---

Internal refactor to no longer use deprecated types
76 changes: 38 additions & 38 deletions plugins/auth-backend/api-report.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion plugins/auth-backend/src/identity/StaticTokenIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AnyJWK, TokenIssuer, TokenParams } from './types';

import { AnyJWK, TokenIssuer } from './types';
import { SignJWT, importJWK, JWK } from 'jose';
import { parseEntityRef } from '@backstage/catalog-model';
import { AuthenticationError } from '@backstage/errors';
import { LoggerService } from '@backstage/backend-plugin-api';
import { StaticKeyStore } from './StaticKeyStore';
import { TokenParams } from '@backstage/plugin-auth-node';

const MS_IN_S = 1000;

Expand Down
5 changes: 3 additions & 2 deletions plugins/auth-backend/src/identity/TokenFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { parseEntityRef } from '@backstage/catalog-model';
import { AuthenticationError } from '@backstage/errors';
import { exportJWK, generateKeyPair, importJWK, JWK, SignJWT } from 'jose';
import { DateTime } from 'luxon';
import { v4 as uuid } from 'uuid';
import { LoggerService } from '@backstage/backend-plugin-api';

import { AnyJWK, KeyStore, TokenIssuer, TokenParams } from './types';
import { TokenParams } from '@backstage/plugin-auth-node';
import { AnyJWK, KeyStore, TokenIssuer } from './types';

const MS_IN_S = 1000;
const MAX_TOKEN_LENGTH = 32768; // At 64 bytes per entity ref this still leaves room for about 500 entities
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth-backend/src/identity/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type TokenIssuer = {
/**
* Issues a new ID Token
*/
issueToken(params: TokenParams): Promise<string>;
issueToken(params: _TokenParams): Promise<string>;

/**
* List all public keys that are currently being used to sign tokens, or have been used
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-backend/src/lib/oauth/OAuthAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import express from 'express';
import { THOUSAND_DAYS_MS, TEN_MINUTES_MS, OAuthAdapter } from './OAuthAdapter';
import { encodeState } from './helpers';
import { OAuthHandlers, OAuthLogoutRequest, OAuthState } from './types';
import { CookieConfigurer } from '../../providers/types';
import { OAuthHandlers, OAuthLogoutRequest } from './types';
import { CookieConfigurer, OAuthState } from '@backstage/plugin-auth-node';

const mockResponseData = {
providerInfo: {
Expand Down
10 changes: 4 additions & 6 deletions plugins/auth-backend/src/lib/oauth/OAuthAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import express, { CookieOptions } from 'express';
import crypto from 'crypto';
import { URL } from 'url';
import {
AuthProviderConfig,
AuthProviderRouteHandlers,
BackstageIdentityResponse,
BackstageSignInResult,
} from '@backstage/plugin-auth-node';
import {
AuthProviderRouteHandlers,
AuthProviderConfig,
CookieConfigurer,
} from '../../providers/types';
OAuthState,
} from '@backstage/plugin-auth-node';
import {
AuthenticationError,
InputError,
Expand All @@ -42,7 +41,6 @@ import {
OAuthHandlers,
OAuthStartRequest,
OAuthRefreshRequest,
OAuthState,
OAuthLogoutRequest,
} from './types';
import { prepareBackstageIdentityResponse } from '../../providers/prepareBackstageIdentityResponse';
Expand Down
4 changes: 2 additions & 2 deletions plugins/auth-backend/src/lib/oauth/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

import express from 'express';
import { OAuthState } from './types';
import { CookieConfigurer } from '../../providers/types';
import {
CookieConfigurer,
OAuthState,
decodeOAuthState,
encodeOAuthState,
} from '@backstage/plugin-auth-node';
Expand Down
3 changes: 2 additions & 1 deletion plugins/auth-backend/src/lib/oauth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import express from 'express';
import { Profile as PassportProfile } from 'passport';
import {
BackstageSignInResult,
ProfileInfo,
OAuthState as _OAuthState,
} from '@backstage/plugin-auth-node';
import { OAuthStartResponse, ProfileInfo } from '../../providers/types';
import { OAuthStartResponse } from '../../providers/types';

/**
* Common options for passport.js-based OAuth providers
Expand Down

0 comments on commit f5e04e3

Please sign in to comment.