pow icon indicating copy to clipboard operation
pow copied to clipboard

Consider moving APIAuthPlug into Pow

Open LandonSchropp opened this issue 3 years ago • 1 comments

I've recently followed the How to use Pow in an API, and overall the experience was great. The very first paragraph of this document is the following:

Pow comes with plug n' play support for Phoenix as HTML web interface. API's work differently, and the developer should have full control over the flow in a proper built API. Therefore Pow encourages that you build custom controllers, and use the plug methods for API integration.

Overall, I very much agree with this philosophy. I was able to tweak the Pow API implementation to suit my application, and the process was very painless.

However, one thing in this approach stood out to me: the APIAuthPlug. I copied this module into my app verbatim, and other than changing MyAppWeb, there wasn't anything in this file specific to my application. Maybe I haven't experienced the full use cases of modifying this file so far, but I'm struggling to see what I would want to modify in this file.

I personally feel like this module should be moved into Pow. I think there are a few benefits of doing so:

  • Keeping this module in Pow helps to maintain the abstractions that Pow provides. Modifying this file seems to require a specific understanding of how Pow works, which I don't think many users of Pow would have (myself included).
  • If the file were moved into Pow, it could be thoroughly tested like the rest of the Pow codebase.
  • If there's ever a need to modify this file in the future, it could be done without any issues with existing applications.

If anyone ever did need to modify the behavior of this file, they could copy it into their application and make the modifications.

If you're open to this change, I'd be happy to do the legwork of getting it into the repo and updating the api.md document.

Thanks!

LandonSchropp avatar Jul 13 '21 19:07 LandonSchropp

@danschultzer Bump.

LandonSchropp avatar Jul 30 '21 19:07 LandonSchropp