stormpath / Turnstile

An authentication framework for Swift.
Apache License 2.0
165 stars 29 forks source link

Support for queries in the url #26

Closed maximedegreve closed 7 years ago

maximedegreve commented 7 years ago

In func exchange(authorizationCodeCallbackURL url: String, state: String) throws -> OAuth2Token {

I think you should use: let redirectURL = url.substring(to: url.range(of: "code")?.lowerBound ?? url.startIndex)

because if you take for the redirection url everything under ? then you end up with a url that doesn't include additional parameters that could have been added in that url.

e.g.."http://0.0.0.0:8080/login-with-facebook/consumer?normal=true normal = true will get cut off

maximedegreve commented 7 years ago

In that case you probably need to remove the "&" before "code" too. If it exists. Great work on this repo btw!

maximedegreve commented 7 years ago

I'm sorry I thought you could store things int he redirect url but reading the docs you can't do this with Oauth.

edjiang commented 7 years ago

You should be able to store stuff in the state parameter in OAuth! This is just a convenience method for Turnstile to do the token exchange, though -- you can always grab stuff from the state if you feel that it's necessary.

Glad you find Turnstile useful!