@azure/msal-browser 5.19.0 → 5.21.0
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/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
- package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
- package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +1 -1
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.mjs +6 -6
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/CacheKeys.mjs +1 -1
- package/dist/cache/CookieStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/EncryptedData.mjs +1 -1
- package/dist/cache/LocalStorage.mjs +15 -5
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/SessionStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +3 -2
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +8 -4
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.mjs +4 -4
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +1 -1
- package/dist/crypto/CryptoOps.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/crypto/TokenBindingKeyManager.mjs +1 -1
- package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
- package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
- package/dist/custom_auth/controller/CustomAuthStandardController.mjs +1 -1
- package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
- package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
- package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
- package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
- package/dist/custom_auth/core/error/HttpError.mjs +1 -1
- package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
- package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
- package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
- package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
- package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
- package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
- package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
- package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
- package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
- package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
- package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
- package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
- package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
- package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
- package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
- package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
- package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
- package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
- package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
- package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
- package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
- package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
- package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
- package/dist/custom_auth/index.mjs +1 -1
- package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
- package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
- package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
- package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
- package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
- package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
- package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
- package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
- package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/PlatformAuthInteractionClient.mjs +1 -1
- package/dist/interaction_client/PopupClient.mjs +7 -3
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +6 -1
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +4 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +6 -3
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +4 -2
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/log-strings-mapping.json +2 -2
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/popup_relay/constants.mjs +1 -1
- package/dist/popup_relay/index.mjs +151 -14
- package/dist/popup_relay/index.mjs.map +1 -1
- package/dist/popup_relay/relayClient.mjs +1 -1
- package/dist/protocol/Authorize.mjs +10 -16
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/redirect_bridge/index.mjs +1 -1
- package/dist/request/RequestHelpers.mjs +63 -10
- package/dist/request/RequestHelpers.mjs.map +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceEvents.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/dist/utils/Helpers.mjs +1 -1
- package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
- package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
- package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
- package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
- package/lib/custom-auth-path/log-strings-mapping.json +2 -2
- package/lib/custom-auth-path/msal-custom-auth.cjs +580 -277
- package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
- package/lib/custom-auth-path/msal-custom-auth.js +580 -277
- package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
- package/lib/log-strings-mapping.json +2 -2
- package/lib/msal-browser.cjs +455 -150
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +455 -150
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +2 -2
- package/lib/popup-relay/msal-popup-relay.cjs +152 -15
- package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
- package/lib/popup-relay/msal-popup-relay.js +152 -15
- package/lib/popup-relay/msal-popup-relay.js.map +1 -1
- package/lib/popup-relay/msal-popup-relay.min.js +2 -2
- package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
- package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
- package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
- package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
- package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
- package/package.json +2 -2
- package/src/cache/BrowserCacheManager.ts +12 -4
- package/src/cache/LocalStorage.ts +14 -4
- package/src/cache/TokenCache.ts +3 -1
- package/src/controllers/NestedAppAuthController.ts +10 -2
- package/src/controllers/StandardController.ts +8 -3
- package/src/controllers/UnknownOperatingContextController.ts +11 -2
- package/src/index.ts +1 -0
- package/src/interaction_client/PopupClient.ts +19 -2
- package/src/interaction_client/RedirectClient.ts +15 -0
- package/src/interaction_client/SilentAuthCodeClient.ts +8 -0
- package/src/interaction_client/SilentIframeClient.ts +11 -5
- package/src/interaction_client/SilentRefreshClient.ts +11 -1
- package/src/packageMetadata.ts +1 -1
- package/src/popup_relay/index.ts +202 -20
- package/src/protocol/Authorize.ts +12 -28
- package/src/request/RequestHelpers.ts +109 -15
- package/src/webBrokerBridge/adapter/CrossVersionRequestAdapter.ts +186 -0
- package/src/webBrokerBridge/index.ts +11 -0
- package/types/cache/BrowserCacheManager.d.ts +3 -3
- package/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/types/cache/LocalStorage.d.ts.map +1 -1
- package/types/cache/TokenCache.d.ts.map +1 -1
- package/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/types/controllers/StandardController.d.ts.map +1 -1
- package/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/interaction_client/PopupClient.d.ts.map +1 -1
- package/types/interaction_client/RedirectClient.d.ts.map +1 -1
- package/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/types/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/types/packageMetadata.d.ts +1 -1
- package/types/popup_relay/index.d.ts +27 -3
- package/types/popup_relay/index.d.ts.map +1 -1
- package/types/protocol/Authorize.d.ts.map +1 -1
- package/types/request/RequestHelpers.d.ts +11 -1
- package/types/request/RequestHelpers.d.ts.map +1 -1
- package/types/webBrokerBridge/adapter/CrossVersionRequestAdapter.d.ts +66 -0
- package/types/webBrokerBridge/adapter/CrossVersionRequestAdapter.d.ts.map +1 -0
- package/types/webBrokerBridge/index.d.ts +2 -0
- package/types/webBrokerBridge/index.d.ts.map +1 -1
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
initializeAuthorizationRequest,
|
|
27
27
|
StandardInteractionClient,
|
|
28
28
|
} from "./StandardInteractionClient.js";
|
|
29
|
+
import { getTokenBindingRequestParams } from "../request/RequestHelpers.js";
|
|
29
30
|
import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
|
|
30
31
|
import {
|
|
31
32
|
ApiId,
|
|
@@ -213,9 +214,16 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
213
214
|
correlationId
|
|
214
215
|
)(this.performanceClient, this.logger, correlationId);
|
|
215
216
|
|
|
217
|
+
const tokenBindingParams = await getTokenBindingRequestParams(
|
|
218
|
+
request,
|
|
219
|
+
this.tokenBindingKeyManager,
|
|
220
|
+
this.logger,
|
|
221
|
+
this.performanceClient
|
|
222
|
+
);
|
|
216
223
|
const redirectRequest = {
|
|
217
224
|
...request,
|
|
218
225
|
codeChallenge: pkceCodes.challenge,
|
|
226
|
+
...tokenBindingParams,
|
|
219
227
|
};
|
|
220
228
|
|
|
221
229
|
this.browserStorage.cacheAuthorizeRequest(
|
|
@@ -318,10 +326,17 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
318
326
|
correlationId
|
|
319
327
|
)(this.performanceClient, this.logger, correlationId);
|
|
320
328
|
|
|
329
|
+
const tokenBindingParams = await getTokenBindingRequestParams(
|
|
330
|
+
request,
|
|
331
|
+
this.tokenBindingKeyManager,
|
|
332
|
+
this.logger,
|
|
333
|
+
this.performanceClient
|
|
334
|
+
);
|
|
321
335
|
const redirectRequest = {
|
|
322
336
|
...request,
|
|
323
337
|
earJwk: earJwk,
|
|
324
338
|
codeChallenge: pkceCodes.challenge,
|
|
339
|
+
...tokenBindingParams,
|
|
325
340
|
};
|
|
326
341
|
|
|
327
342
|
this.browserStorage.cacheAuthorizeRequest(
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
initializeAuthorizationRequest,
|
|
19
19
|
StandardInteractionClient,
|
|
20
20
|
} from "./StandardInteractionClient.js";
|
|
21
|
+
import { getTokenBindingRequestParams } from "../request/RequestHelpers.js";
|
|
21
22
|
import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
|
|
22
23
|
import { BrowserConfiguration } from "../config/Configuration.js";
|
|
23
24
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager.js";
|
|
@@ -114,10 +115,17 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
114
115
|
);
|
|
115
116
|
|
|
116
117
|
try {
|
|
118
|
+
const tokenBindingParams = await getTokenBindingRequestParams(
|
|
119
|
+
silentRequest,
|
|
120
|
+
this.tokenBindingKeyManager,
|
|
121
|
+
this.logger,
|
|
122
|
+
this.performanceClient
|
|
123
|
+
);
|
|
117
124
|
// Create auth code request (PKCE not needed)
|
|
118
125
|
const authCodeRequest: CommonAuthorizationCodeRequest = {
|
|
119
126
|
...silentRequest,
|
|
120
127
|
code: request.code,
|
|
128
|
+
...tokenBindingParams,
|
|
121
129
|
};
|
|
122
130
|
|
|
123
131
|
// Initialize the client
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
initializeAuthorizationRequest,
|
|
24
24
|
StandardInteractionClient,
|
|
25
25
|
} from "./StandardInteractionClient.js";
|
|
26
|
+
import { getTokenBindingRequestParams } from "../request/RequestHelpers.js";
|
|
26
27
|
import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
|
|
27
28
|
import { BrowserConfiguration } from "../config/Configuration.js";
|
|
28
29
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager.js";
|
|
@@ -543,10 +544,8 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
543
544
|
authClient: AuthorizationCodeClient,
|
|
544
545
|
request: CommonAuthorizationUrlRequest
|
|
545
546
|
): Promise<AuthenticationResult> {
|
|
546
|
-
const { serverParams, pkceCodes } =
|
|
547
|
-
authClient,
|
|
548
|
-
request
|
|
549
|
-
);
|
|
547
|
+
const { serverParams, pkceCodes, silentRequest } =
|
|
548
|
+
await this.silentAuthorizeHelper(authClient, request);
|
|
550
549
|
|
|
551
550
|
return invokeAsync(
|
|
552
551
|
Authorize.handleResponseCode,
|
|
@@ -555,7 +554,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
555
554
|
this.performanceClient,
|
|
556
555
|
request.correlationId
|
|
557
556
|
)(
|
|
558
|
-
|
|
557
|
+
silentRequest,
|
|
559
558
|
serverParams,
|
|
560
559
|
pkceCodes.verifier,
|
|
561
560
|
this.apiId,
|
|
@@ -593,9 +592,16 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
593
592
|
correlationId
|
|
594
593
|
)(this.performanceClient, this.logger, correlationId);
|
|
595
594
|
|
|
595
|
+
const tokenBindingParams = await getTokenBindingRequestParams(
|
|
596
|
+
request,
|
|
597
|
+
this.tokenBindingKeyManager,
|
|
598
|
+
this.logger,
|
|
599
|
+
this.performanceClient
|
|
600
|
+
);
|
|
596
601
|
const silentRequest = {
|
|
597
602
|
...request,
|
|
598
603
|
codeChallenge: pkceCodes.challenge,
|
|
604
|
+
...tokenBindingParams,
|
|
599
605
|
};
|
|
600
606
|
|
|
601
607
|
// Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
|
|
@@ -21,7 +21,10 @@ import {
|
|
|
21
21
|
BrowserAuthErrorCodes,
|
|
22
22
|
} from "../error/BrowserAuthError.js";
|
|
23
23
|
import { AuthenticationResult } from "../response/AuthenticationResult.js";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
initializeBaseRequest,
|
|
26
|
+
getTokenBindingRequestParams,
|
|
27
|
+
} from "../request/RequestHelpers.js";
|
|
25
28
|
import {
|
|
26
29
|
getRedirectUri,
|
|
27
30
|
initializeServerTelemetryManager,
|
|
@@ -48,9 +51,16 @@ export class SilentRefreshClient extends StandardInteractionClient {
|
|
|
48
51
|
this.logger,
|
|
49
52
|
this.correlationId
|
|
50
53
|
);
|
|
54
|
+
const tokenBindingParams = await getTokenBindingRequestParams(
|
|
55
|
+
baseRequest,
|
|
56
|
+
this.tokenBindingKeyManager,
|
|
57
|
+
this.logger,
|
|
58
|
+
this.performanceClient
|
|
59
|
+
);
|
|
51
60
|
const silentRequest: CommonSilentFlowRequest = {
|
|
52
61
|
...request,
|
|
53
62
|
...baseRequest,
|
|
63
|
+
...tokenBindingParams,
|
|
54
64
|
};
|
|
55
65
|
|
|
56
66
|
if (request.redirectUri) {
|
package/src/packageMetadata.ts
CHANGED
package/src/popup_relay/index.ts
CHANGED
|
@@ -24,6 +24,24 @@ export type PopupRelayOptions = {
|
|
|
24
24
|
* before giving up. Defaults to 300000 (5 minutes).
|
|
25
25
|
*/
|
|
26
26
|
timeoutMs?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Origins the relay is allowed to navigate its IdP child popup to, e.g.
|
|
29
|
+
* `["https://login.microsoftonline.com"]`. Strongly recommended: set this
|
|
30
|
+
* to the origin(s) of the authority your app signs in against, so the relay
|
|
31
|
+
* page can only ever be used to reach your identity provider.
|
|
32
|
+
*
|
|
33
|
+
* Entries are compared by origin, so passing the full configured authority
|
|
34
|
+
* (`"https://login.microsoftonline.com/common"`), a trailing slash, mixed
|
|
35
|
+
* case, or an explicit `:443` all work.
|
|
36
|
+
*
|
|
37
|
+
* **Optional — omitting it does not disable the relay.** The relay page
|
|
38
|
+
* always rejects non-`https:` navigation targets; this option additionally
|
|
39
|
+
* pins *which* https origins are acceptable. When omitted, any https origin
|
|
40
|
+
* is allowed, which is how every existing relay page already behaves.
|
|
41
|
+
* Passing an explicitly empty array means "allow nothing" and will reject
|
|
42
|
+
* every navigation.
|
|
43
|
+
*/
|
|
44
|
+
allowedAuthorityOrigins?: string[];
|
|
27
45
|
};
|
|
28
46
|
|
|
29
47
|
type PopupRelayRequest = { id: string } & (
|
|
@@ -35,6 +53,176 @@ const DEFAULT_POPUP_RELAY_TIMEOUT_MS = 300000;
|
|
|
35
53
|
const DEFAULT_POPUP_RELAY_WIDTH = 520;
|
|
36
54
|
const DEFAULT_POPUP_RELAY_HEIGHT = 640;
|
|
37
55
|
|
|
56
|
+
const BAD_REQUEST_SUBERROR = "popup_relay_bad_request";
|
|
57
|
+
const UNSAFE_URL_SUBERROR = "popup_relay_unsafe_url";
|
|
58
|
+
const UNTRUSTED_AUTHORITY_SUBERROR = "popup_relay_untrusted_authority";
|
|
59
|
+
const INVALID_ALLOWED_ORIGIN_SUBERROR = "popup_relay_invalid_allowed_origin";
|
|
60
|
+
|
|
61
|
+
function throwRelayError(subError: string): never {
|
|
62
|
+
throw createBrowserAuthError(
|
|
63
|
+
BrowserAuthErrorCodes.popupRelayUnsupportedFlow,
|
|
64
|
+
"",
|
|
65
|
+
subError
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function tryParseUrl(raw: string): URL | null {
|
|
70
|
+
try {
|
|
71
|
+
return new URL(raw);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reduces each configured allow-list entry to its origin so the comparison is
|
|
79
|
+
* robust to the shapes a developer naturally reaches for. Passing the
|
|
80
|
+
* configured authority (`https://login.microsoftonline.com/common`), a trailing
|
|
81
|
+
* slash, mixed case, or an explicit default port all normalize to the same
|
|
82
|
+
* origin the navigation target is compared against.
|
|
83
|
+
*
|
|
84
|
+
* A malformed entry is a configuration bug in the relay page, and silently
|
|
85
|
+
* dropping it would quietly change the size of the allow list, so it fails
|
|
86
|
+
* loudly instead.
|
|
87
|
+
*/
|
|
88
|
+
function normalizeAllowedOrigins(allowedAuthorityOrigins: string[]): string[] {
|
|
89
|
+
return allowedAuthorityOrigins.map((entry) => {
|
|
90
|
+
const parsed = typeof entry === "string" ? tryParseUrl(entry) : null;
|
|
91
|
+
if (
|
|
92
|
+
!parsed ||
|
|
93
|
+
parsed.protocol !== "https:" ||
|
|
94
|
+
parsed.username ||
|
|
95
|
+
parsed.password
|
|
96
|
+
) {
|
|
97
|
+
throwRelayError(INVALID_ALLOWED_ORIGIN_SUBERROR);
|
|
98
|
+
}
|
|
99
|
+
return parsed.origin;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Validates a navigation target taken from the relay page's hash before it can
|
|
105
|
+
* reach `window.open` or a form `action`.
|
|
106
|
+
*
|
|
107
|
+
* The hash is *not* authority: anyone can craft a link to the deployed relay
|
|
108
|
+
* page, so a target must be proven safe rather than assumed to have been built
|
|
109
|
+
* by MSAL. Only absolute `https:` URLs without embedded credentials are
|
|
110
|
+
* accepted, which rules out active/local schemes (`javascript:`, `data:`,
|
|
111
|
+
* `blob:`, `vbscript:`, `file:`) that would otherwise execute in — or read
|
|
112
|
+
* from — the relay page's own first-party security origin. `https:`-only also
|
|
113
|
+
* matches the scheme MSAL already requires of an authority, so it cannot reject
|
|
114
|
+
* a navigation MSAL would have been willing to build.
|
|
115
|
+
*
|
|
116
|
+
* When `allowedAuthorityOrigins` is omitted the origin check is skipped and any
|
|
117
|
+
* https target is accepted — the behavior every relay page had before this
|
|
118
|
+
* validation existed. An explicitly empty array means "allow nothing" and is
|
|
119
|
+
* honored as such rather than being treated as "unset".
|
|
120
|
+
*/
|
|
121
|
+
function validateNavigationTarget(
|
|
122
|
+
raw: unknown,
|
|
123
|
+
allowedAuthorityOrigins?: string[]
|
|
124
|
+
): string {
|
|
125
|
+
if (typeof raw !== "string" || !raw) {
|
|
126
|
+
throwRelayError(BAD_REQUEST_SUBERROR);
|
|
127
|
+
}
|
|
128
|
+
const parsed = tryParseUrl(raw);
|
|
129
|
+
if (
|
|
130
|
+
!parsed ||
|
|
131
|
+
parsed.protocol !== "https:" ||
|
|
132
|
+
parsed.username ||
|
|
133
|
+
parsed.password
|
|
134
|
+
) {
|
|
135
|
+
throwRelayError(UNSAFE_URL_SUBERROR);
|
|
136
|
+
}
|
|
137
|
+
if (
|
|
138
|
+
allowedAuthorityOrigins !== undefined &&
|
|
139
|
+
!Array.isArray(allowedAuthorityOrigins)
|
|
140
|
+
) {
|
|
141
|
+
throwRelayError(INVALID_ALLOWED_ORIGIN_SUBERROR);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const normalizedAllowedOrigins =
|
|
145
|
+
allowedAuthorityOrigins === undefined
|
|
146
|
+
? undefined
|
|
147
|
+
: normalizeAllowedOrigins(allowedAuthorityOrigins);
|
|
148
|
+
|
|
149
|
+
if (
|
|
150
|
+
normalizedAllowedOrigins &&
|
|
151
|
+
normalizedAllowedOrigins.indexOf(parsed.origin) < 0
|
|
152
|
+
) {
|
|
153
|
+
throwRelayError(UNTRUSTED_AUTHORITY_SUBERROR);
|
|
154
|
+
}
|
|
155
|
+
/*
|
|
156
|
+
* Return the original string rather than `parsed.href`: `window.open` and
|
|
157
|
+
* `form.action` resolve it with the same URL parser used here, so the
|
|
158
|
+
* navigation is byte-identical to what MSAL built and no normalization can
|
|
159
|
+
* alter an authority's query encoding.
|
|
160
|
+
*/
|
|
161
|
+
return raw;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Parses and fully validates the relayed request carried in the relay page's
|
|
166
|
+
* hash. Every field is treated as attacker-controlled: the shape is checked
|
|
167
|
+
* exactly (no implicit GET fallback for an unknown `method`) and both
|
|
168
|
+
* navigation targets — the GET `url` and the POST `action` — are run through
|
|
169
|
+
* {@link validateNavigationTarget}.
|
|
170
|
+
*/
|
|
171
|
+
function parseRelayRequest(
|
|
172
|
+
rawReq: string,
|
|
173
|
+
allowedAuthorityOrigins?: string[]
|
|
174
|
+
): PopupRelayRequest {
|
|
175
|
+
let parsed;
|
|
176
|
+
try {
|
|
177
|
+
parsed = JSON.parse(rawReq);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
parsed = null;
|
|
180
|
+
}
|
|
181
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
182
|
+
throwRelayError(BAD_REQUEST_SUBERROR);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const request = parsed as Record<string, unknown>;
|
|
186
|
+
const id = request.id;
|
|
187
|
+
if (typeof id !== "string" || !id) {
|
|
188
|
+
throwRelayError(BAD_REQUEST_SUBERROR);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (request.method === "GET") {
|
|
192
|
+
return {
|
|
193
|
+
id,
|
|
194
|
+
method: "GET",
|
|
195
|
+
url: validateNavigationTarget(request.url, allowedAuthorityOrigins),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (request.method === "POST") {
|
|
200
|
+
const action = validateNavigationTarget(
|
|
201
|
+
request.action,
|
|
202
|
+
allowedAuthorityOrigins
|
|
203
|
+
);
|
|
204
|
+
const rawFields = request.fields;
|
|
205
|
+
if (
|
|
206
|
+
typeof rawFields !== "object" ||
|
|
207
|
+
rawFields === null ||
|
|
208
|
+
Array.isArray(rawFields)
|
|
209
|
+
) {
|
|
210
|
+
throwRelayError(BAD_REQUEST_SUBERROR);
|
|
211
|
+
}
|
|
212
|
+
const fields: Record<string, string> = {};
|
|
213
|
+
Object.keys(rawFields).forEach((name) => {
|
|
214
|
+
const value = (rawFields as Record<string, unknown>)[name];
|
|
215
|
+
if (typeof value !== "string") {
|
|
216
|
+
throwRelayError(BAD_REQUEST_SUBERROR);
|
|
217
|
+
}
|
|
218
|
+
fields[name] = value;
|
|
219
|
+
});
|
|
220
|
+
return { id, method: "POST", action, fields };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return throwRelayError(BAD_REQUEST_SUBERROR);
|
|
224
|
+
}
|
|
225
|
+
|
|
38
226
|
/**
|
|
39
227
|
* Builds the `window.open` features string for the IdP child popup from a
|
|
40
228
|
* {@link PopupWindowAttributes}, mirroring the shape used by
|
|
@@ -61,13 +249,19 @@ function buildChildPopupFeatures(attributes?: PopupWindowAttributes): string {
|
|
|
61
249
|
*
|
|
62
250
|
* 1. Reads the IdP navigation MSAL passed in this page's hash (a GET URL, or a
|
|
63
251
|
* POST form for the form_post / EAR response modes), then scrubs the hash.
|
|
64
|
-
* 2.
|
|
252
|
+
* 2. Validates that navigation. The relay page is directly reachable, so the
|
|
253
|
+
* hash is untrusted input: the request shape is checked exactly and the
|
|
254
|
+
* navigation target must be an absolute `https:` URL (optionally pinned to
|
|
255
|
+
* {@link PopupRelayOptions.allowedAuthorityOrigins}). Anything else — in
|
|
256
|
+
* particular active schemes such as `javascript:` — is rejected before it
|
|
257
|
+
* can reach `window.open` or a form `action`.
|
|
258
|
+
* 3. Opens the IdP child popup and performs that navigation (the relay page
|
|
65
259
|
* stays put, so its `window.opener` link back to the embedded frame
|
|
66
260
|
* survives COOP).
|
|
67
|
-
*
|
|
261
|
+
* 4. Waits for the child's redirect URI page (which must run the redirect
|
|
68
262
|
* bridge, `broadcastResponseToMainFrame`) to broadcast the raw auth
|
|
69
263
|
* response over a same-origin `BroadcastChannel`.
|
|
70
|
-
*
|
|
264
|
+
* 5. Relays that raw response back to the embedded frame via
|
|
71
265
|
* `opener.postMessage`, posting only to its own (same) origin, then closes.
|
|
72
266
|
*
|
|
73
267
|
* The embedded frame keeps the PKCE verifier (and EAR private key) and exchanges
|
|
@@ -105,23 +299,11 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
|
|
|
105
299
|
);
|
|
106
300
|
}
|
|
107
301
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
BrowserAuthErrorCodes.popupRelayUnsupportedFlow,
|
|
114
|
-
"",
|
|
115
|
-
"popup_relay_bad_request"
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
if (!request || !request.id) {
|
|
119
|
-
throw createBrowserAuthError(
|
|
120
|
-
BrowserAuthErrorCodes.popupRelayUnsupportedFlow,
|
|
121
|
-
"",
|
|
122
|
-
"popup_relay_bad_request"
|
|
123
|
-
);
|
|
124
|
-
}
|
|
302
|
+
/*
|
|
303
|
+
* Validate everything before opening anything: the relay page is directly
|
|
304
|
+
* reachable, so the hash is attacker-controlled input, not authority.
|
|
305
|
+
*/
|
|
306
|
+
const request = parseRelayRequest(rawReq, options?.allowedAuthorityOrigins);
|
|
125
307
|
|
|
126
308
|
const id = request.id;
|
|
127
309
|
const channel = new BroadcastChannel(id);
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
IPerformanceClient,
|
|
14
14
|
Logger,
|
|
15
15
|
PerformanceEvents,
|
|
16
|
-
PopTokenGenerator,
|
|
17
16
|
ProtocolMode,
|
|
18
17
|
RequestParameterBuilder,
|
|
19
18
|
CommonAuthorizationCodeRequest,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
AuthorizationCodePayload,
|
|
27
26
|
ServerAuthorizationTokenResponse,
|
|
28
27
|
Constants,
|
|
28
|
+
AADServerParamKeys,
|
|
29
29
|
} from "@azure/msal-common/browser";
|
|
30
30
|
import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
|
|
31
31
|
import { BrowserConfiguration } from "../config/Configuration.js";
|
|
@@ -187,37 +187,21 @@ async function getStandardParameters(
|
|
|
187
187
|
|
|
188
188
|
// pass the req_cnf for POP
|
|
189
189
|
if (
|
|
190
|
-
request.authenticationScheme ===
|
|
190
|
+
request.authenticationScheme ===
|
|
191
|
+
Constants.AuthenticationScheme.POP &&
|
|
192
|
+
request.reqCnf
|
|
191
193
|
) {
|
|
192
|
-
|
|
193
|
-
const tokenBindingKeyManager = new TokenBindingKeyManager(
|
|
194
|
-
logger,
|
|
195
|
-
performanceClient
|
|
196
|
-
);
|
|
197
|
-
const popTokenGenerator = new PopTokenGenerator(
|
|
198
|
-
cryptoOps,
|
|
199
|
-
tokenBindingKeyManager,
|
|
200
|
-
performanceClient
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
// req_cnf is always sent as a string for SPAs
|
|
204
|
-
let reqCnfData;
|
|
205
|
-
if (!request.popKid) {
|
|
206
|
-
const generatedReqCnfData = await invokeAsync(
|
|
207
|
-
popTokenGenerator.generateCnf.bind(popTokenGenerator),
|
|
208
|
-
PerformanceEvents.PopTokenGenerateCnf,
|
|
209
|
-
logger,
|
|
210
|
-
performanceClient,
|
|
211
|
-
request.correlationId
|
|
212
|
-
)(request, logger);
|
|
213
|
-
reqCnfData = generatedReqCnfData.reqCnfString;
|
|
214
|
-
} else {
|
|
215
|
-
reqCnfData = cryptoOps.encodeKid(request.popKid);
|
|
216
|
-
}
|
|
217
|
-
RequestParameterBuilder.addPopToken(parameters, reqCnfData);
|
|
194
|
+
RequestParameterBuilder.addPopToken(parameters, request.reqCnf);
|
|
218
195
|
}
|
|
219
196
|
}
|
|
220
197
|
|
|
198
|
+
if (
|
|
199
|
+
request.authenticationScheme === Constants.AuthenticationScheme.DPOP &&
|
|
200
|
+
request.dpopJkt
|
|
201
|
+
) {
|
|
202
|
+
parameters.set(AADServerParamKeys.DPOP_JKT, request.dpopJkt);
|
|
203
|
+
}
|
|
204
|
+
|
|
221
205
|
RequestParameterBuilder.instrumentBrokerParams(
|
|
222
206
|
parameters,
|
|
223
207
|
request.correlationId,
|
|
@@ -8,10 +8,15 @@ import {
|
|
|
8
8
|
Constants,
|
|
9
9
|
BaseAuthRequest,
|
|
10
10
|
ClientConfigurationErrorCodes,
|
|
11
|
+
CommonAuthorizationUrlRequest,
|
|
11
12
|
CommonSilentFlowRequest,
|
|
12
13
|
IPerformanceClient,
|
|
14
|
+
ITokenBindingKeyManager,
|
|
13
15
|
Logger,
|
|
14
16
|
ProtocolMode,
|
|
17
|
+
JsonWebTokenAlgorithms,
|
|
18
|
+
PerformanceEvents,
|
|
19
|
+
PopTokenGenerator,
|
|
15
20
|
createClientConfigurationError,
|
|
16
21
|
invokeAsync,
|
|
17
22
|
} from "@azure/msal-common/browser";
|
|
@@ -20,13 +25,110 @@ import { BrowserConfiguration } from "../config/Configuration.js";
|
|
|
20
25
|
import { SilentRequest } from "./SilentRequest.js";
|
|
21
26
|
import { PopupRequest } from "./PopupRequest.js";
|
|
22
27
|
import { RedirectRequest } from "./RedirectRequest.js";
|
|
28
|
+
import { CryptoOps } from "../crypto/CryptoOps.js";
|
|
23
29
|
|
|
24
30
|
const SUPPORTED_AUTHENTICATION_SCHEMES = new Set<string>([
|
|
25
31
|
Constants.AuthenticationScheme.BEARER,
|
|
26
32
|
Constants.AuthenticationScheme.POP,
|
|
33
|
+
Constants.AuthenticationScheme.DPOP,
|
|
27
34
|
Constants.AuthenticationScheme.SSH,
|
|
28
35
|
]);
|
|
29
36
|
|
|
37
|
+
function validateSshRequest(
|
|
38
|
+
request: Partial<BaseAuthRequest>,
|
|
39
|
+
correlationId: string
|
|
40
|
+
): void {
|
|
41
|
+
if (!request.sshJwk) {
|
|
42
|
+
throw createClientConfigurationError(
|
|
43
|
+
ClientConfigurationErrorCodes.missingSshJwk,
|
|
44
|
+
correlationId
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (!request.sshKid) {
|
|
48
|
+
throw createClientConfigurationError(
|
|
49
|
+
ClientConfigurationErrorCodes.missingSshKid,
|
|
50
|
+
correlationId
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function validateDpopRequest(
|
|
56
|
+
request: Partial<BaseAuthRequest>,
|
|
57
|
+
correlationId: string
|
|
58
|
+
): void {
|
|
59
|
+
if (
|
|
60
|
+
!request.resourceRequestMethod?.trim() ||
|
|
61
|
+
!request.resourceRequestUri?.trim()
|
|
62
|
+
) {
|
|
63
|
+
throw createClientConfigurationError(
|
|
64
|
+
ClientConfigurationErrorCodes.dpopMissingResourceContext,
|
|
65
|
+
correlationId
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the token-binding parameters needed before building authorize or token requests.
|
|
72
|
+
* Public PCA DPoP requests use a dpopJkt thumbprint, while platform broker PoP requests use
|
|
73
|
+
* a reqCnf confirmation claim. Requests that do not require request-time token binding return
|
|
74
|
+
* no additional parameters.
|
|
75
|
+
*/
|
|
76
|
+
export async function getTokenBindingRequestParams(
|
|
77
|
+
request: Partial<BaseAuthRequest> & {
|
|
78
|
+
correlationId: string;
|
|
79
|
+
platformBroker?: boolean;
|
|
80
|
+
},
|
|
81
|
+
tokenBindingKeyManager: ITokenBindingKeyManager,
|
|
82
|
+
logger: Logger,
|
|
83
|
+
performanceClient: IPerformanceClient
|
|
84
|
+
): Promise<Pick<CommonAuthorizationUrlRequest, "dpopJkt" | "reqCnf">> {
|
|
85
|
+
switch (request.authenticationScheme) {
|
|
86
|
+
case Constants.AuthenticationScheme.DPOP:
|
|
87
|
+
if (request.platformBroker) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (request.dpopJkt) {
|
|
92
|
+
return { dpopJkt: request.dpopJkt };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
dpopJkt: await tokenBindingKeyManager.provisionTokenBindingKey({
|
|
97
|
+
tokenBindingKeyType:
|
|
98
|
+
Constants.AuthenticationScheme.DPOP.toLowerCase(),
|
|
99
|
+
tokenBindingKeyAlgorithm: JsonWebTokenAlgorithms.ES256,
|
|
100
|
+
correlationId: request.correlationId,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
case Constants.AuthenticationScheme.POP:
|
|
104
|
+
if (!request.platformBroker) {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const cryptoOps = new CryptoOps(logger, performanceClient);
|
|
109
|
+
if (request.popKid) {
|
|
110
|
+
return { reqCnf: cryptoOps.encodeKid(request.popKid) };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const popTokenGenerator = new PopTokenGenerator(
|
|
114
|
+
cryptoOps,
|
|
115
|
+
tokenBindingKeyManager,
|
|
116
|
+
performanceClient
|
|
117
|
+
);
|
|
118
|
+
const generatedReqCnfData = await invokeAsync(
|
|
119
|
+
popTokenGenerator.generateCnf.bind(popTokenGenerator),
|
|
120
|
+
PerformanceEvents.PopTokenGenerateCnf,
|
|
121
|
+
logger,
|
|
122
|
+
performanceClient,
|
|
123
|
+
request.correlationId
|
|
124
|
+
)(request, logger);
|
|
125
|
+
|
|
126
|
+
return { reqCnf: generatedReqCnfData.reqCnfString };
|
|
127
|
+
default:
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
30
132
|
/**
|
|
31
133
|
* Initializer function for all request APIs
|
|
32
134
|
* @param request
|
|
@@ -73,21 +175,13 @@ export async function initializeBaseRequest(
|
|
|
73
175
|
);
|
|
74
176
|
}
|
|
75
177
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
correlationId
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
if (!request.sshKid) {
|
|
87
|
-
throw createClientConfigurationError(
|
|
88
|
-
ClientConfigurationErrorCodes.missingSshKid,
|
|
89
|
-
correlationId
|
|
90
|
-
);
|
|
178
|
+
switch (validatedRequest.authenticationScheme) {
|
|
179
|
+
case Constants.AuthenticationScheme.SSH:
|
|
180
|
+
validateSshRequest(request, correlationId);
|
|
181
|
+
break;
|
|
182
|
+
case Constants.AuthenticationScheme.DPOP: {
|
|
183
|
+
validateDpopRequest(request, correlationId);
|
|
184
|
+
break;
|
|
91
185
|
}
|
|
92
186
|
}
|
|
93
187
|
logger.verbose(
|