Skip to content

Commit 1d2df17

Browse files
authored
Merge pull request #1565 from AzureAD/ameyapat/request-bound-rt-api
API to get signed JWT request for redeeming bound application refresh tokens
2 parents 24ba8ff + 25cdc35 commit 1d2df17

10 files changed

+1617
-1
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@
747747
720B5B582DD58A7F00318FE5 /* MSIDJWECryptoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 720B5B572DD58A6A00318FE5 /* MSIDJWECryptoTests.m */; };
748748
720B5B592DD58A7F00318FE5 /* MSIDJWECryptoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 720B5B572DD58A6A00318FE5 /* MSIDJWECryptoTests.m */; };
749749
72371CEB27051CC200EF5475 /* MSIDKeyOperationUtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72371CEA27051CC200EF5475 /* MSIDKeyOperationUtilTest.m */; };
750+
724C9DD42E6906290039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 724C9DD32E6906270039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m */; };
751+
724C9DD52E6906290039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 724C9DD32E6906270039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m */; };
750752
728209C326FA9C9A00B5F018 /* MSIDBackgroundTaskData.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209C226FA9C9A00B5F018 /* MSIDBackgroundTaskData.m */; };
751753
728209C926FE94D800B5F018 /* MSIDJwtAlgorithm.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209C826FE94D800B5F018 /* MSIDJwtAlgorithm.m */; };
752754
728209CA26FE94D800B5F018 /* MSIDJwtAlgorithm.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209C826FE94D800B5F018 /* MSIDJwtAlgorithm.m */; };
@@ -769,6 +771,12 @@
769771
7293580E2DDFADDF0001D03C /* MSIDNonceHttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7293580D2DDFADC80001D03C /* MSIDNonceHttpRequest.h */; };
770772
729358102DDFADE70001D03C /* MSIDNonceHttpRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293580F2DDFADE50001D03C /* MSIDNonceHttpRequest.m */; };
771773
729358112DDFADE70001D03C /* MSIDNonceHttpRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293580F2DDFADE50001D03C /* MSIDNonceHttpRequest.m */; };
774+
72978AEB2E4C246F00DEA46D /* MSIDBoundRefreshToken+Redemption.h in Headers */ = {isa = PBXBuildFile; fileRef = 72978AEA2E4C240B00DEA46D /* MSIDBoundRefreshToken+Redemption.h */; };
775+
72978AED2E4C248700DEA46D /* MSIDBoundRefreshToken+Redemption.m in Sources */ = {isa = PBXBuildFile; fileRef = 72978AEC2E4C248500DEA46D /* MSIDBoundRefreshToken+Redemption.m */; };
776+
72978AEE2E4C248700DEA46D /* MSIDBoundRefreshToken+Redemption.m in Sources */ = {isa = PBXBuildFile; fileRef = 72978AEC2E4C248500DEA46D /* MSIDBoundRefreshToken+Redemption.m */; };
777+
72978AF02E4C2A4C00DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 72978AEF2E4C2A1E00DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.h */; };
778+
72978AF22E4C2C3500DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 72978AF12E4C2C3300DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m */; };
779+
72978AF32E4C2C3500DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 72978AF12E4C2C3300DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m */; };
772780
72C1EBF52DE91AC8004C40A4 /* MSIDBoundRefreshToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 72C1EBF42DE91ABE004C40A4 /* MSIDBoundRefreshToken.h */; };
773781
72C1EBF72DE91AD0004C40A4 /* MSIDBoundRefreshToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C1EBF62DE91ACC004C40A4 /* MSIDBoundRefreshToken.m */; };
774782
72C1EBF82DE91AD0004C40A4 /* MSIDBoundRefreshToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C1EBF62DE91ACC004C40A4 /* MSIDBoundRefreshToken.m */; };
@@ -2676,6 +2684,7 @@
26762684
720B5B542DD57D6600318FE5 /* MSIDEcdhApv.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDEcdhApv.m; sourceTree = "<group>"; };
26772685
720B5B572DD58A6A00318FE5 /* MSIDJWECryptoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDJWECryptoTests.m; sourceTree = "<group>"; };
26782686
72371CEA27051CC200EF5475 /* MSIDKeyOperationUtilTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDKeyOperationUtilTest.m; sourceTree = "<group>"; };
2687+
724C9DD32E6906270039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBoundRefreshTokenRedemptionTests.m; sourceTree = "<group>"; };
26792688
728209C126FA9C9A00B5F018 /* MSIDBackgroundTaskData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBackgroundTaskData.h; sourceTree = "<group>"; };
26802689
728209C226FA9C9A00B5F018 /* MSIDBackgroundTaskData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBackgroundTaskData.m; sourceTree = "<group>"; };
26812690
728209C826FE94D800B5F018 /* MSIDJwtAlgorithm.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDJwtAlgorithm.m; sourceTree = "<group>"; };
@@ -2692,6 +2701,10 @@
26922701
729357F22DDBD3F60001D03C /* MSIDNonceTokenRequestTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDNonceTokenRequestTest.m; sourceTree = "<group>"; };
26932702
7293580D2DDFADC80001D03C /* MSIDNonceHttpRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDNonceHttpRequest.h; sourceTree = "<group>"; };
26942703
7293580F2DDFADE50001D03C /* MSIDNonceHttpRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDNonceHttpRequest.m; sourceTree = "<group>"; };
2704+
72978AEA2E4C240B00DEA46D /* MSIDBoundRefreshToken+Redemption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MSIDBoundRefreshToken+Redemption.h"; sourceTree = "<group>"; };
2705+
72978AEC2E4C248500DEA46D /* MSIDBoundRefreshToken+Redemption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MSIDBoundRefreshToken+Redemption.m"; sourceTree = "<group>"; };
2706+
72978AEF2E4C2A1E00DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBoundRefreshTokenRedemptionParameters.h; sourceTree = "<group>"; };
2707+
72978AF12E4C2C3300DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBoundRefreshTokenRedemptionParameters.m; sourceTree = "<group>"; };
26952708
72C1EBF42DE91ABE004C40A4 /* MSIDBoundRefreshToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBoundRefreshToken.h; sourceTree = "<group>"; };
26962709
72C1EBF62DE91ACC004C40A4 /* MSIDBoundRefreshToken.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBoundRefreshToken.m; sourceTree = "<group>"; };
26972710
72C1EBFB2DEA8185004C40A4 /* MSIDBoundRefreshTokenCacheItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBoundRefreshTokenCacheItem.h; sourceTree = "<group>"; };
@@ -4936,6 +4949,8 @@
49364949
B251CC232041050E005E0179 /* token */ = {
49374950
isa = PBXGroup;
49384951
children = (
4952+
72978AEC2E4C248500DEA46D /* MSIDBoundRefreshToken+Redemption.m */,
4953+
72978AEA2E4C240B00DEA46D /* MSIDBoundRefreshToken+Redemption.h */,
49394954
72C1EBF62DE91ACC004C40A4 /* MSIDBoundRefreshToken.m */,
49404955
72C1EBF42DE91ABE004C40A4 /* MSIDBoundRefreshToken.h */,
49414956
B2675689228CE6FC000F01D7 /* protocols */,
@@ -5162,6 +5177,8 @@
51625177
B2AF1D3D218BD02F0080C1A0 /* parameters */ = {
51635178
isa = PBXGroup;
51645179
children = (
5180+
72978AF12E4C2C3300DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m */,
5181+
72978AEF2E4C2A1E00DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.h */,
51655182
B2968C8322F3C3E8005AFC33 /* MSIDBrokerInvocationOptions.h */,
51665183
B2968C8422F3C3E8005AFC33 /* MSIDBrokerInvocationOptions.m */,
51675184
B2AF1D3E218BD10A0080C1A0 /* MSIDRequestParameters.h */,
@@ -5745,6 +5762,7 @@
57455762
D6DA89731FBA6A4E004C56C7 /* tests */ = {
57465763
isa = PBXGroup;
57475764
children = (
5765+
724C9DD32E6906270039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m */,
57485766
4BADFA5D2E85D7EC00E8C26F /* MSIDFlightManagerTests.swift */,
57495767
2318D7882E12B8E800A5A46E /* MSIDBrokerOperationBrowserNativeMessageMATSReportTests.m */,
57505768
72C764F82E09CFA400043AB1 /* MSIDBoundRefreshTokenTests.m */,
@@ -6302,6 +6320,7 @@
63026320
230016402371126E00F7D19C /* MSIDProviderType.h in Headers */,
63036321
235480CD20DDF81000246F72 /* MSIDAADTenant.h in Headers */,
63046322
B26A0B822071B6CC006BD95A /* MSIDAADOauth2Factory.h in Headers */,
6323+
72978AEB2E4C246F00DEA46D /* MSIDBoundRefreshToken+Redemption.h in Headers */,
63056324
B2DD4B2620A7D67C0047A66E /* MSIDLegacyRefreshToken.h in Headers */,
63066325
B2C707F32192524700D917B8 /* MSIDDefaultTokenRequestProvider.h in Headers */,
63076326
B286B9772389CE67007833AD /* MSIDWebOAuth2Response.h in Headers */,
@@ -6457,6 +6476,7 @@
64576476
23B39AB7209BC705000AA905 /* MSIDOpenIdProviderMetadata.h in Headers */,
64586477
1E707FE32407338000716148 /* MSIDBrokerOperationResponseHandling.h in Headers */,
64596478
72D961AE2DE12F1F005DED66 /* MSIDCachedNonce.h in Headers */,
6479+
72978AF02E4C2A4C00DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.h in Headers */,
64606480
23391BD62B17F2FD00EB121B /* MSIDBrowserNativeMessageSignOutRequest.h in Headers */,
64616481
238A04932089A3C800989EE0 /* MSIDHttpRequestTelemetry.h in Headers */,
64626482
B286B9C62389DE7B007833AD /* MSIDAccountMetadataCacheKey.h in Headers */,
@@ -7138,6 +7158,7 @@
71387158
2347D6692D5453A400372D20 /* MSIDSwitchBrowserOperationTest.swift in Sources */,
71397159
23419F82239B36F500EA78C5 /* MSIDAccountIdentifierTests.m in Sources */,
71407160
589BDB1D2718CD7D00BF3799 /* MSIDBrokerOperationGetSsoCookiesRequestTests.m in Sources */,
7161+
724C9DD52E6906290039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m in Sources */,
71417162
B210F42E1FDDE6A5005A8F76 /* MSIDJsonObjectTests.m in Sources */,
71427163
B2E97FB32914CC4500AFD558 /* MSIDBrokerNativeAppOperationResponseTests.m in Sources */,
71437164
B29F7805213DFA5600D61FC8 /* MSIDErrorTests.m in Sources */,
@@ -7485,6 +7506,7 @@
74857506
237777CC2853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m in Sources */,
74867507
B251CC1D2040F6B5005E0179 /* MSIDLegacyTokenCacheKey.m in Sources */,
74877508
1EE541422458B30300A86414 /* MSIDDevicePopManager.m in Sources */,
7509+
72978AF22E4C2C3500DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m in Sources */,
74887510
B239564A27A8DF6B00684CA5 /* MSIDWPJKeyPairWithCert.m in Sources */,
74897511
B2525C6C23302364006FBA4B /* MSIDMainThreadUtil.m in Sources */,
74907512
2306D2A020AB672A00F875A3 /* MSIDAADEndpointProvider.m in Sources */,
@@ -7494,6 +7516,7 @@
74947516
235480D120DDF81000246F72 /* MSIDADFSAuthority.m in Sources */,
74957517
23391BD82B17F2FD00EB121B /* MSIDBrowserNativeMessageSignOutRequest.m in Sources */,
74967518
B2EF143B1FF2F228005DC1C0 /* MSIDAADV2TokenResponse.m in Sources */,
7519+
72978AEE2E4C248700DEA46D /* MSIDBoundRefreshToken+Redemption.m in Sources */,
74977520
B2C708AC219A5A3D00D917B8 /* MSIDLegacySilentTokenRequest.m in Sources */,
74987521
B20657BF1FC9254900412B7D /* MSIDTelemetryCacheEvent.m in Sources */,
74997522
B2000C9E20EC65600092790A /* MSIDURLFormObject.m in Sources */,
@@ -7776,6 +7799,7 @@
77767799
96CD652A20C885E2004813EE /* MSIDWebviewFactoryTests.m in Sources */,
77777800
239DF9C220E04BC9002D428B /* MSIDB2CAuthorityTests.m in Sources */,
77787801
B281B339226BBB1C009619AB /* MSIDOAuthRequestConfiguratorTests.m in Sources */,
7802+
724C9DD42E6906290039BAA0 /* MSIDBoundRefreshTokenRedemptionTests.m in Sources */,
77797803
B2808005204CB2A700944D89 /* MSIDAADV1TokenResponseTests.m in Sources */,
77807804
23419F64239896E500EA78C5 /* MSIDBrokerOperationResponseTests.m in Sources */,
77817805
D6D9A4BD1FBE712900EFA430 /* MSIDURLExtensionsTests.m in Sources */,
@@ -8000,6 +8024,7 @@
80008024
B2000C8F20EC63210092790A /* MSIDDefaultCredentialCacheKey.m in Sources */,
80018025
B2AF1D41218BD10A0080C1A0 /* MSIDRequestParameters.m in Sources */,
80028026
1E3590B9216D210E003D43BE /* MSIDAppMetadataCacheKey.m in Sources */,
8027+
72978AED2E4C248700DEA46D /* MSIDBoundRefreshToken+Redemption.m in Sources */,
80038028
B2A3C2822145D2760082525C /* MSIDCredentialCacheItem.m in Sources */,
80048029
1EC0AB482499764700EAF327 /* MSIDCacheConfig.m in Sources */,
80058030
B251CC392041058D005E0179 /* MSIDLegacySingleResourceToken.m in Sources */,
@@ -8257,6 +8282,7 @@
82578282
1E4D74AB216E7AE70091426A /* MSIDGeneralCacheItemType.m in Sources */,
82588283
B286B96323861852007833AD /* MSIDSignoutWebRequestConfiguration.m in Sources */,
82598284
B49323982AD4DA4800E0CBC0 /* MSIDBrokerOperationGetPasskeyAssertionResponse.m in Sources */,
8285+
72978AF32E4C2C3500DEA46D /* MSIDBoundRefreshTokenRedemptionParameters.m in Sources */,
82608286
B2C708182195283500D917B8 /* MSIDBrokerTokenRequest.m in Sources */,
82618287
72C1EBF82DE91AD0004C40A4 /* MSIDBoundRefreshToken.m in Sources */,
82628288
232173E22182A998009852C6 /* NSDictionary+MSIDJsonSerializable.m in Sources */,

IdentityCore/src/MSIDOAuth2Constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,5 @@ extern NSString *const MSID_CCS_REQUEST_ID_RESPONSE;
180180
extern NSString *const MSID_CCS_REQUEST_SEQUENCE_KEY;
181181
extern NSString *const MSID_CCS_REQUEST_SEQUENCE_RESPONSE;
182182
extern NSString *const MSID_BOUND_DEVICE_ID_CACHE_KEY;
183+
extern NSString *const MSID_MSAL_CLIENT_APV_PREFIX;
184+
extern NSString *const MSID_BOUND_REFRESH_TOKEN_EXCHANGE;

IdentityCore/src/MSIDOAuth2Constants.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,6 @@
180180
NSString *const MSID_CCS_REQUEST_SEQUENCE_KEY = @"x-ms-srs";
181181
NSString *const MSID_CCS_REQUEST_SEQUENCE_RESPONSE = @"ccs-request-sequence";
182182

183+
NSString *const MSID_BOUND_REFRESH_TOKEN_EXCHANGE = @"bound_rt_exchange";
183184
NSString *const MSID_BOUND_DEVICE_ID_CACHE_KEY = @"bound_device_id";
185+
NSString *const MSID_MSAL_CLIENT_APV_PREFIX = @"MsalClient";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
#import "MSIDBoundRefreshToken.h"
26+
#import "MSIDBoundRefreshTokenRedemptionParameters.h"
27+
28+
NS_ASSUME_NONNULL_BEGIN
29+
@interface MSIDBoundRefreshToken (Redemption)
30+
/*!
31+
@brief For specified tenant ID, get a signed JWT request to redeem this bound refresh token. Tenant ID is used to query registration and match device ID from it to this bound refresh token.
32+
@param tenantId The tenant ID that will be used to query the device registration.
33+
@param jweCrypto Optional dictionary to receive JWE crypto information. It will be also part of the resulting JWT's payload.
34+
@param error Pointer to an NSError object that will be set if an error occurs.
35+
@return A JWT string for token redemption, or nil if an error occurs.
36+
*/
37+
- (NSString *) getTokenRedemptionJwtForTenantId: (nullable NSString *)tenantId
38+
tokenRedemptionParameters: (MSIDBoundRefreshTokenRedemptionParameters *)requestParameters
39+
context:(id<MSIDRequestContext> _Nullable)context
40+
jweCrypto: (NSDictionary *__nonnull *__nonnull)jweCrypto
41+
error: (NSError *__nonnull __autoreleasing *__nonnull)error;
42+
@end
43+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)