OAuth 2.0 provider for Elixir and Phoenix

oauth2
#1

In short
Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependency and run the install task. That’s it! :rocket:

ExOauth2Provider
PhoenixOauth2Provider

Background
This is my first full project in Elixir. The reason for building these hex libraries was that I needed a flexible plug n’ play OAuth 2.0 provider for a Phoenix project I’m working on. The other options I found didn’t cut it for me, and I was looking for something akin to Doorkeeper for Rails. Basically a no brainer library, that I can adjust after getting it up and running.

Use case
I wrote a blog post on how you can create a versioned API using OAuth 2.0 access tokens in minutes using this library: https://dreamconception.com/tech/phoenix-full-fledged-api-in-five-minutes/

I hope this can be useful for some of you. Please feel free to help improve the libraries with suggestions or PR’s!

10 Likes
#2

I’ve made a few updates since I wrote this post. Now there’s added support for UUID (or custom primary key type), and works with Phoenix 1.3. Blog post has been updated too. All feedback is welcome :rocket:

6 Likes
#3

Thanks a ton @danschultzer

#4

Finally got around to rewriting these libraries. With Pow I got a much better idea how these libraries should work.

It will be much easier to contribute to them moving forward :rocket: It was a major rewrite so there are probably a lot of things that can be refactored, and I have overlooked. Any help would be much appreciated!

ExOauth2Provider v0.5.0 changes

Changelog

  • Schema modules are now generated (with mix ex_oauth2_provider.gen.schemas). Now all configuration (e.g. binary id) are done on the individual schema modules. Previously there were issues if e.g. some app environment was not available during compilation, and configuration wasn’t particularly explicit.
  • Configuration are primarily passed through the method calls with fallback to app environment.
  • Ecto 3.0 support.

PhoenixOauth2Provider 0.5.0

Changelog

  • Templates are now built in so you can get started without generating any views/templates!
  • Phoenix 1.4 support.
1 Like
#5

Just updated the tutorial and demo app too:

https://dreamconception.com/tech/phoenix-full-fledged-api-in-five-minutes/

https://github.com/danschultzer/phoenix_ex_oauth2_provider_demo

Happy coding!

2 Likes