-
Notifications
You must be signed in to change notification settings - Fork 225
SDK: Refresh Token implementation #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
43a8858
First pass at refresh token support using existing httpClient token r…
langleyd 34fe5dd
Move HTTPClient to pull in access token vs hold a reference. Use disp…
langleyd 79d101f
Update http refresh mechanism naming and documentation to more accura…
langleyd 360c056
Add preemptive expiry
langleyd 9ad4f77
Add token persistence handler to syncrhonize token data access from d…
langleyd 3589712
Merge branch 'develop' of github.com:matrix-org/matrix-ios-sdk into l…
langleyd e280c4c
Improve error handling.
langleyd ced463c
Fix tests.
langleyd 7465d4d
Fix MXCredentials equality
langleyd 8977baa
Add softLogout and refreshTokenAuth to callback for analytics
langleyd 9dc2771
Merge branch 'develop' of github.com:matrix-org/matrix-ios-sdk into l…
langleyd 7da1e08
Update MXCoreDataRoomListDataManagerUnitTests.swift
langleyd 634b47c
Fix preemptive refresh code (had changed to debug errors)
langleyd 8e8bb79
Fix one case where refresh token might not be persisted if RestClient…
langleyd 35fa763
Merge branch 'develop' of github.com:matrix-org/matrix-ios-sdk into l…
langleyd 98c2efd
Fix naming of `expiresInMs` in `MXRefreshTokenData` and the logic to …
langleyd b9cbc3b
Make MXRefreshTokenData readonly
langleyd 7e44b4d
Api cleanup.
langleyd 60902b8
Move MXRefreshResponse to it's own file.
langleyd fa0d781
put back nil equality check
langleyd 4660b34
Fix nullability of refresh response.
langleyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // | ||
| // Copyright 2021 New Vector Ltd | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
|
|
||
| /** | ||
| `MXRefreshTokenData` used to update `MXCredentials` that it's token data has updated. see `MXCredentialsUpdateTokensNotification`. | ||
| */ | ||
| @interface MXRefreshTokenData : NSObject | ||
langleyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| The user id. | ||
| */ | ||
| @property (nonatomic, readonly, nonnull) NSString *userId; | ||
|
|
||
| /** | ||
| The homeserver URL. | ||
| */ | ||
| @property (nonatomic, readonly, nonnull) NSString *homeserver; | ||
|
|
||
|
|
||
| /** | ||
| The access token to create a MXRestClient | ||
| */ | ||
| @property (nonatomic, readonly, nonnull) NSString *accessToken; | ||
|
|
||
| /** | ||
| The timestamp in milliseconds for when the access token will expire | ||
| */ | ||
| @property (nonatomic, readonly) uint64_t accessTokenExpiresAt; | ||
|
|
||
| /** | ||
| The refresh token, which can be used to obtain new access tokens. (optional) | ||
| */ | ||
| @property (nonatomic, readonly, nullable) NSString *refreshToken; | ||
|
|
||
| - (instancetype _Nonnull)initWithUserId:(NSString*_Nonnull)userId | ||
| homeserver:(NSString*_Nonnull)homeserver | ||
| accessToken:(NSString*_Nonnull)accessToken | ||
| refreshToken:(NSString*_Nonnull)refreshToken | ||
| accessTokenExpiresAt:(uint64_t)accessTokenExpiresAt; | ||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // | ||
| // MXRefreshTokenData.m | ||
| // MatrixSDK | ||
| // | ||
| // Created by David Langley on 17/12/2021. | ||
| // | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
| #import "MXRefreshTokenData.h" | ||
|
|
||
| @implementation MXRefreshTokenData | ||
| - (instancetype)initWithUserId:(NSString*)userId | ||
| homeserver:(NSString*)homeserver | ||
| accessToken:(NSString*)accessToken | ||
| refreshToken:(NSString*)refreshToken | ||
| accessTokenExpiresAt:(uint64_t)accessTokenExpiresAt | ||
| { | ||
| self = [super init]; | ||
| if (self) | ||
| { | ||
| _userId = userId; | ||
| _homeserver = homeserver; | ||
| _accessToken = accessToken; | ||
| _refreshToken = refreshToken; | ||
| _accessTokenExpiresAt = accessTokenExpiresAt; | ||
| } | ||
| return self; | ||
| } | ||
|
|
||
| @end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.