Skip to content
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

Oauth #50

Merged
merged 38 commits into from
Jun 12, 2018
Merged

Oauth #50

merged 38 commits into from
Jun 12, 2018

Conversation

cainlevy
Copy link
Member

@cainlevy cainlevy commented May 8, 2018

Adds OAuth support to AuthN.

In this setup, AuthN hides all of the OAuth 2.0 implementation details from the main application. The main application redirects users through AuthN and then relies on the refresh endpoint to acquire an identity token.

An AuthN account may have a linked identity with each configured provider.

Only Google OAuth has been implemented, but other providers are easy to add.

Currently there is no way for the application to know if a user's session originated with OAuth. In the future, AuthN may provide the application with the user's current access token for business logic.

Outcomes

There are three success outcomes of the OAuth integration:

  1. Login -- if the provider identity has been linked before, AuthN will establish a session for the existing account. The application should already have a user profile.
  2. Account Connection -- if the provider identity is unknown but AuthN has a valid session for an account that has not linked to the provider, then AuthN will connect the identity to the existing account.
  3. Signup -- if the provider identity is unknown and AuthN does not have a current session, then AuthN will attempt to create a new account with the linked identity. The application should detect a missing user profile and finish registration.

Failure outcomes include:

  • Attempting to redirect to a URL that does not match one of the configure application domains
  • Tampering with the OAuth return URL
  • Attempting a CSRF attack on the OAuth return action
  • Taking more than an hour to complete the OAuth flow
  • Attempting to authenticate with a locked account

TODO

  • integration proof with demo app
  • Docs on new config variables
  • Docs on howto
  • More provider integrations (Facebook & GitHub are priorities)
  • List the new feature (beta)

Fixes #11

Provider is now a struct, not an interface. The constructor requires all
the necessary bits.

This makes it easier to put common behavior somewhere, like injecting
the return URL or adding extra scopes (TBD).
this enables google oauth integration. ideally the others only need a
single credential pair as well.
in some degenerate cases we must return to a failsafe url
i can't see how it's necessary here. should clean this up.
@k1ng440
Copy link

k1ng440 commented May 24, 2018

does it work now?

@cainlevy
Copy link
Member Author

yes! 🎉

i currently have it working in a demo app, and have written some basic docs for how to integrate. i've been ill the past few days, though, and haven't settled on a release plan.

if you're in a position to build and try this branch that would be awesome. otherwise i'll plan on making a new release of authn with oauth in some kind of beta status.

@cainlevy
Copy link
Member Author

@cainlevy cainlevy merged commit e2580fb into master Jun 12, 2018
@cainlevy cainlevy deleted the oauth branch June 12, 2018 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants