-
Notifications
You must be signed in to change notification settings - Fork 231
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
Native Authentication support #86
Conversation
@@ -21,9 +21,9 @@ Pod::Spec.new do |s| | |||
s.ios.source_files = 'Auth0/*.{swift,h,m}' | |||
s.ios.frameworks = 'UIKit', 'SafariServices' | |||
s.osx.source_files = 'Auth0/*.swift' | |||
s.osx.exclude_files = 'Auth0/_ObjectiveWebAuth.swift', 'Auth0/ControllerModalPresenter.swift', 'Auth0/OAuth2Grant.swift', 'Auth0/OAuth2Session.swift', 'Auth0/SessionStorage.swift', 'Auth0/WebAuth.swift', 'Auth0/WebAuthError.swift', 'Auth0/SafariWebAuth.swift' | |||
s.osx.exclude_files = 'Auth0/_ObjectiveWebAuth.swift', 'Auth0/ControllerModalPresenter.swift', 'Auth0/OAuth2Grant.swift', 'Auth0/AuthTransaction.swift', 'Auth0/TransactionStore.swift', 'Auth0/WebAuth.swift', 'Auth0/WebAuthError.swift', 'Auth0/SafariWebAuth.swift' |
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.
Shouldn't we exclude native auth file?
import SafariServices | ||
|
||
/** | ||
Represents an on going AuthTransaction with Auth0. |
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.
Represents an on going Auth transaction with an Identity Provider (Auth0 or a third party).
/** | ||
Represents an on going AuthTransaction with Auth0. | ||
|
||
It will handle result from the redirect URL configured when the AuthTransaction flow was started, |
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.
Since the Auth will be done outside the application control, Safari or third party IdP App, the only way to communicate the results back is using an url with a registered custom scheme in our application so iOS can open it on success/failure. When that happens iOS will call a method in your AppDelegate
and there is where we need to handle the result.
|
||
import UIKit | ||
|
||
public protocol AuthProvider { |
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.
docs?
let token: String | ||
let extras: [String: Any] | ||
|
||
public init(token: String, extras: [String: Any]) { |
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.
Make public the attributes instead of creating an init
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.
Thought I had did this for a reason, if you want a public structure type to be initializable with a memberwise initializer when used in another module, you must provide a public memberwise initializer yourself.
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.
unless both attributes are public so it should infer the constructor
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.
It will infer for the project but not when imported. Source
nativeAuthCredentials.extras.forEach { key, value in parameters[key] = value } | ||
|
||
authentication().loginSocial(token: nativeAuthCredentials.token, connection: connection, scope: scope, parameters: parameters) | ||
.start { callback($0) } |
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.
Just pass the callback as the parameter why wrapping it up in another one?
static let sharedInstance = SessionStorage() | ||
/// Keeps track of current Auth Transaction | ||
class TransactionStore { | ||
static let sharedInstance = TransactionStore() |
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.
Now that we are modifying it let's use the shared
name instead
func login(withConnection connection: String, scope: String, parameters: [String: Any]) -> NativeAuthTransaction | ||
} | ||
|
||
public struct NativeAuthCredentials { |
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.
docs?
func auth(callback: @escaping Callback) -> () | ||
} | ||
|
||
public extension NativeAuthTransaction { |
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.
doc?
@@ -0,0 +1,74 @@ | |||
// NativeAuth.swift |
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.
I believe we might need to split the file in parts
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.
I broke out AuthProvider, everything left is NativeAuth*
Scope, connnection and parameters are used in the final stage of Auth Transaction during the Auth0 Social Authentication. | ||
|
||
``` | ||
class SocialNativeTransaction: NativeAuthTransaction { |
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.
I am not buying this example, it does not explain what each method does and what the parameter are for, what are the properties. Also it is not showing any real case usage.
We need to document each protocol property and method explaining what it does
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.
Have fleshed this out, let's see how it feels.
e14787f
to
03805e1
Compare
03805e1
to
1fc08ca
Compare
Rename SessionStorage to TransactionStore, implements AuthStorage Rename OAuth2Session to AuthTransaction Update tests Separate AuthTransaction / SafariSession code Remove session references in TransactionStore
Code Style changes
1fc08ca
to
33e7482
Compare
Improved NativeAuthTransaction tests
2b7b65a
to
1c7d306
Compare
Adds support for native authentication with a third party IdP using their iOS SDK and then performing the Auth against Auth0.