-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add authentication before checking for updates #6
Conversation
} | ||
} | ||
|
||
private class PresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to make this configurable so users can pass in their own ASWebAuthenticationPresentationContextProviding
@@ -125,6 +143,9 @@ public final class ETDistribution: NSObject { | |||
} | |||
var request = URLRequest(url: url) | |||
request.httpMethod = "GET" | |||
if let accessToken = accessToken { | |||
request.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the response handling I think we need a case for when the authorization was invalid. Like if the token was manually revoke. Seems like right now the user will be stuck until the system time > refresh time. Instead if the authorization is invalid I think we should try to refresh it and if that fails show the login screen. We can also handle the case where the loginSetting
wasn't provided but we get back an authorization error to automatically show the login screen
] as CFDictionary | ||
|
||
var result: AnyObject? | ||
let status = SecItemCopyMatching(query, &result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple says to call these functions on a background thread: https://developer.apple.com/documentation/security/secitemcopymatching(_:_:)#Performance-considerations
No description provided.