@backstage/core-app-api 1.6.0 → 1.7.0-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,31 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 1.7.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1e4f5e91b8e: Bump `zod` and `zod-to-json-schema` dependencies.
8
+ - e0c6e8b9c3c: Update peer dependencies
9
+ - Updated dependencies
10
+ - @backstage/core-plugin-api@1.5.1-next.0
11
+ - @backstage/version-bridge@1.0.4-next.0
12
+ - @backstage/config@1.0.7
13
+ - @backstage/types@1.0.2
14
+
15
+ ## 1.7.0-next.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 7908d72e033: Introduce a new global config parameter, `auth.enableExperimentalRedirectFlow`. When enabled, auth will happen with an in-window redirect flow rather than through a popup window.
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @backstage/core-plugin-api@1.5.0
25
+ - @backstage/config@1.0.7
26
+ - @backstage/types@1.0.2
27
+ - @backstage/version-bridge@1.0.3
28
+
3
29
  ## 1.6.0
4
30
 
5
31
  ### Minor Changes
package/config.d.ts CHANGED
@@ -115,4 +115,11 @@ export interface Config {
115
115
  */
116
116
  environment?: string;
117
117
  };
118
+
119
+ /**
120
+ $ Enable redirect authentication flow type, instead of a popup for authentication
121
+ * default value: 'false'
122
+ * @visibility frontend
123
+ */
124
+ enableExperimentalRedirectFlow?: boolean;
118
125
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, PropsWithChildren, ComponentType } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi, SessionState, AuthRequestOptions, BackstageIdentityResponse, ProfileInfo, oktaAuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
3
+ import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, ConfigApi, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi, SessionState, AuthRequestOptions, BackstageIdentityResponse, ProfileInfo, oktaAuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
4
4
  import * as _backstage_types from '@backstage/types';
5
5
  import { Observable, JsonValue } from '@backstage/types';
6
6
  import { Config, AppConfig } from '@backstage/config';
@@ -107,6 +107,7 @@ declare type AuthApiCreateOptions = {
107
107
  discoveryApi: DiscoveryApi;
108
108
  environment?: string;
109
109
  provider?: AuthProviderInfo;
110
+ configApi?: ConfigApi;
110
111
  };
111
112
 
112
113
  /**
@@ -218,6 +219,7 @@ declare class MicrosoftAuth {
218
219
  * @public
219
220
  */
220
221
  declare type OneLoginAuthCreateOptions = {
222
+ configApi?: ConfigApi;
221
223
  discoveryApi: DiscoveryApi;
222
224
  oauthRequestApi: OAuthRequestApi;
223
225
  environment?: string;
@@ -613,7 +615,7 @@ declare type BootErrorPageProps = {
613
615
  */
614
616
  declare type SignInPageProps = {
615
617
  /**
616
- * Set the IdentityApi on successful sign in. This should only be called once.
618
+ * Set the IdentityApi on successful sign-in. This should only be called once.
617
619
  */
618
620
  onSignInSuccess(identityApi: IdentityApi): void;
619
621
  };
package/dist/index.esm.js CHANGED
@@ -215,12 +215,15 @@ function showLoginPopup(options) {
215
215
  });
216
216
  }
217
217
 
218
+ let warned$1 = false;
218
219
  function defaultJoinScopes(scopes) {
219
220
  return [...scopes].join(" ");
220
221
  }
221
222
  class DefaultAuthConnector {
222
223
  constructor(options) {
224
+ var _a;
223
225
  const {
226
+ configApi,
224
227
  discoveryApi,
225
228
  environment,
226
229
  provider,
@@ -228,9 +231,21 @@ class DefaultAuthConnector {
228
231
  oauthRequestApi,
229
232
  sessionTransform = (id) => id
230
233
  } = options;
234
+ if (!warned$1 && !configApi) {
235
+ console.warn(
236
+ "DEPRECATION WARNING: Authentication providers require a configApi instance to configure the authentication flow. Please provide one to the authentication provider constructor."
237
+ );
238
+ warned$1 = true;
239
+ }
240
+ this.enableExperimentalRedirectFlow = configApi ? (_a = configApi.getOptionalBoolean("enableExperimentalRedirectFlow")) != null ? _a : false : false;
231
241
  this.authRequester = oauthRequestApi.createAuthRequester({
232
242
  provider,
233
- onAuthRequest: (scopes) => this.showPopup(scopes)
243
+ onAuthRequest: async (scopes) => {
244
+ if (!this.enableExperimentalRedirectFlow) {
245
+ return this.showPopup(scopes);
246
+ }
247
+ return this.executeRedirect(scopes);
248
+ }
234
249
  });
235
250
  this.discoveryApi = discoveryApi;
236
251
  this.environment = environment;
@@ -240,6 +255,9 @@ class DefaultAuthConnector {
240
255
  }
241
256
  async createSession(options) {
242
257
  if (options.instantPopup) {
258
+ if (this.enableExperimentalRedirectFlow) {
259
+ return this.executeRedirect(options.scopes);
260
+ }
243
261
  return this.showPopup(options.scopes);
244
262
  }
245
263
  return this.authRequester(options.scopes);
@@ -293,7 +311,8 @@ class DefaultAuthConnector {
293
311
  const scope = this.joinScopesFunc(scopes);
294
312
  const popupUrl = await this.buildUrl("/start", {
295
313
  scope,
296
- origin: window.location.origin
314
+ origin: window.location.origin,
315
+ flow: "popup"
297
316
  });
298
317
  const payload = await showLoginPopup({
299
318
  url: popupUrl,
@@ -304,6 +323,17 @@ class DefaultAuthConnector {
304
323
  });
305
324
  return await this.sessionTransform(payload);
306
325
  }
326
+ async executeRedirect(scopes) {
327
+ const scope = this.joinScopesFunc(scopes);
328
+ window.location.href = await this.buildUrl("/start", {
329
+ scope,
330
+ origin: window.location.origin,
331
+ redirectUrl: window.location.href,
332
+ flow: "redirect"
333
+ });
334
+ return new Promise(() => {
335
+ });
336
+ }
307
337
  async buildUrl(path, query) {
308
338
  const baseUrl = await this.discoveryApi.getBaseUrl("auth");
309
339
  const queryString = this.buildQueryString({
@@ -775,6 +805,7 @@ const DEFAULT_PROVIDER$a = {
775
805
  class OAuth2 {
776
806
  static create(options) {
777
807
  const {
808
+ configApi,
778
809
  discoveryApi,
779
810
  environment = "development",
780
811
  provider = DEFAULT_PROVIDER$a,
@@ -783,6 +814,7 @@ class OAuth2 {
783
814
  scopeTransform = (x) => x
784
815
  } = options;
785
816
  const connector = new DefaultAuthConnector({
817
+ configApi,
786
818
  discoveryApi,
787
819
  environment,
788
820
  provider,
@@ -870,6 +902,7 @@ const DEFAULT_PROVIDER$9 = {
870
902
  class GithubAuth {
871
903
  static create(options) {
872
904
  const {
905
+ configApi,
873
906
  discoveryApi,
874
907
  environment = "development",
875
908
  provider = DEFAULT_PROVIDER$9,
@@ -877,6 +910,7 @@ class GithubAuth {
877
910
  defaultScopes = ["read:user"]
878
911
  } = options;
879
912
  return OAuth2.create({
913
+ configApi,
880
914
  discoveryApi,
881
915
  oauthRequestApi,
882
916
  provider,
@@ -894,6 +928,7 @@ const DEFAULT_PROVIDER$8 = {
894
928
  class GitlabAuth {
895
929
  static create(options) {
896
930
  const {
931
+ configApi,
897
932
  discoveryApi,
898
933
  environment = "development",
899
934
  provider = DEFAULT_PROVIDER$8,
@@ -901,6 +936,7 @@ class GitlabAuth {
901
936
  defaultScopes = ["read_user"]
902
937
  } = options;
903
938
  return OAuth2.create({
939
+ configApi,
904
940
  discoveryApi,
905
941
  oauthRequestApi,
906
942
  provider,
@@ -919,6 +955,7 @@ const SCOPE_PREFIX$1 = "https://www.googleapis.com/auth/";
919
955
  class GoogleAuth {
920
956
  static create(options) {
921
957
  const {
958
+ configApi,
922
959
  discoveryApi,
923
960
  oauthRequestApi,
924
961
  environment = "development",
@@ -930,6 +967,7 @@ class GoogleAuth {
930
967
  ]
931
968
  } = options;
932
969
  return OAuth2.create({
970
+ configApi,
933
971
  discoveryApi,
934
972
  oauthRequestApi,
935
973
  provider,
@@ -971,6 +1009,7 @@ const OKTA_SCOPE_PREFIX = "okta.";
971
1009
  class OktaAuth {
972
1010
  static create(options) {
973
1011
  const {
1012
+ configApi,
974
1013
  discoveryApi,
975
1014
  environment = "development",
976
1015
  provider = DEFAULT_PROVIDER$6,
@@ -978,6 +1017,7 @@ class OktaAuth {
978
1017
  defaultScopes = ["openid", "email", "profile", "offline_access"]
979
1018
  } = options;
980
1019
  return OAuth2.create({
1020
+ configApi,
981
1021
  discoveryApi,
982
1022
  oauthRequestApi,
983
1023
  provider,
@@ -1071,6 +1111,7 @@ const DEFAULT_PROVIDER$4 = {
1071
1111
  class MicrosoftAuth {
1072
1112
  static create(options) {
1073
1113
  const {
1114
+ configApi,
1074
1115
  environment = "development",
1075
1116
  provider = DEFAULT_PROVIDER$4,
1076
1117
  oauthRequestApi,
@@ -1084,6 +1125,7 @@ class MicrosoftAuth {
1084
1125
  ]
1085
1126
  } = options;
1086
1127
  return OAuth2.create({
1128
+ configApi,
1087
1129
  discoveryApi,
1088
1130
  oauthRequestApi,
1089
1131
  provider,
@@ -1111,12 +1153,14 @@ const SCOPE_PREFIX = "onelogin.";
1111
1153
  class OneLoginAuth {
1112
1154
  static create(options) {
1113
1155
  const {
1156
+ configApi,
1114
1157
  discoveryApi,
1115
1158
  environment = "development",
1116
1159
  provider = DEFAULT_PROVIDER$3,
1117
1160
  oauthRequestApi
1118
1161
  } = options;
1119
1162
  return OAuth2.create({
1163
+ configApi,
1120
1164
  discoveryApi,
1121
1165
  oauthRequestApi,
1122
1166
  provider,
@@ -1145,6 +1189,7 @@ const DEFAULT_PROVIDER$2 = {
1145
1189
  class BitbucketAuth {
1146
1190
  static create(options) {
1147
1191
  const {
1192
+ configApi,
1148
1193
  discoveryApi,
1149
1194
  environment = "development",
1150
1195
  provider = DEFAULT_PROVIDER$2,
@@ -1152,6 +1197,7 @@ class BitbucketAuth {
1152
1197
  defaultScopes = ["team"]
1153
1198
  } = options;
1154
1199
  return OAuth2.create({
1200
+ configApi,
1155
1201
  discoveryApi,
1156
1202
  oauthRequestApi,
1157
1203
  provider,
@@ -1169,6 +1215,7 @@ const DEFAULT_PROVIDER$1 = {
1169
1215
  class BitbucketServerAuth {
1170
1216
  static create(options) {
1171
1217
  const {
1218
+ configApi,
1172
1219
  discoveryApi,
1173
1220
  environment = "development",
1174
1221
  provider = DEFAULT_PROVIDER$1,
@@ -1176,6 +1223,7 @@ class BitbucketServerAuth {
1176
1223
  defaultScopes = ["PROJECT_ADMIN"]
1177
1224
  } = options;
1178
1225
  return OAuth2.create({
1226
+ configApi,
1179
1227
  discoveryApi,
1180
1228
  oauthRequestApi,
1181
1229
  provider,
@@ -1193,12 +1241,14 @@ const DEFAULT_PROVIDER = {
1193
1241
  class AtlassianAuth {
1194
1242
  static create(options) {
1195
1243
  const {
1244
+ configApi,
1196
1245
  discoveryApi,
1197
1246
  environment = "development",
1198
1247
  provider = DEFAULT_PROVIDER,
1199
1248
  oauthRequestApi
1200
1249
  } = options;
1201
1250
  return OAuth2.create({
1251
+ configApi,
1202
1252
  discoveryApi,
1203
1253
  oauthRequestApi,
1204
1254
  provider,