dwyl / hapi-auth-github

:octocat: GitHub Authentication Plugin for Hapi.js Apps Quick/Easy/Secure/Tested
GNU General Public License v2.0
17 stars 3 forks source link

Create Elixir version of this module? #28

Closed iteles closed 1 year ago

iteles commented 6 years ago

As our tech stack has now evolved github.com/dwyl/technology-stack , I'd like to explore having this module as an elixir module rather than hapi.

The idea is for us to have a login module that we can pick up and run with for future projects without having to rebuild a login for every project.

The key is that the module is:

This one is next: https://github.com/dwyl/hapi-auth-google

finnhodgkin commented 6 years ago

There's a pretty great module for Github/Google/Twitter OAuth that requires minimal setup - Ueberauth. It doesn't handle cookies, jwts or storing users in a db, just the actual OAuth flow. I wrote a WiP guide that uses it a couple weeks ago:

https://github.com/finnhodgkin/learn-phoenix-todo-example#oauth-authentication

I could pare this down to just the bits of code required for authentication, because Ueberauth really does do a great job of OAuth flow.

The only issue is that it's hard to tell how much test coverage it has. There are some tests, but they look more like business logic tests than blanket coverage. It's the highest result on Google (in an incognito tab) for Pheonix Authentication and seems to be top of everyone's recommendation list, but sometimes that doesn't mean much :woman_shrugging:

finnhodgkin commented 6 years ago

There's definitely room for a module wrapped around Ueberauth that handles the app-specific authentication stuff (cookies, protected routes, etc.), but IMO circumventing Ueberauth entirely and writing an OAuth flow from scratch would be a big time sink for a very similar wheel, at least at the start.

We could start by setting up a module around Ueberauth and then think about replacing it after..?

ZooeyMiller commented 6 years ago

I ran code coverage on ueberauth, and their coverage is high, but not 100%.

terminal_037

Rather than making something from scratch, we could potentially look into adding tests to ueberauth to bring it up to 100%.

iteles commented 6 years ago

I would say that it would be an excellent learning exercise to write up the implementation plan for something like this (being built from scratch) as well as for utilising ueberauth; both of which should be broken down and estimated.

iteles commented 6 years ago

@ZooeyMiller Whilst that is certainly a potential solution; from experience, it's unlikely that the 100% test coverage would be maintained without us policing it. Creating that kind of dependency on us is also quite taxing and ultimately not worthwhile.

We push hard with our clients to allow us to spend the time to get to 100% test coverage because it makes everyone's lives so much easier in terms of minimising bugs and especially for future maintenance.

finnhodgkin commented 6 years ago

Implementation plan for a github oauth plugin for elixir.

Things what we should think about

What features does hapi-auth-github have?

Our idea of an "MVP" for this module would be to have it so the the module handles:

The user would still have to handle:

How long would it take?

Breakdown

Quite hard to judge specifics until we've done some more research on building modules

Total: 12-14hrs

Implementation for ueberauth

I would say, rather than creating a module for use with ueberauth if that is what we decided, we would write a detailed tutorial for ueberauth with github, extending that which @finnhodgkin has already written here: https://github.com/finnhodgkin/learn-phoenix-todo-example#oauth-authentication

iteles commented 6 years ago

@finnhodgkin @ZooeyMiller The breakdown of the various spike you'll have to do is great!

Carrying out these spikes and documenting your learning in the appropriate repo (that might even be learn-elixir or learn-phoenix) is a great learning experience. This is all core knowledge that all Elixir developers who come after you will need. Definitely worth dedicating a couple of days to.

nelsonic commented 1 year ago

https://github.com/dwyl/elixir-auth-github