4 ms·
If you're okay with OAuth providers then https://github.com/markbates/goth https://github.com/markbates/goth gives you the capability to handle more than just G
by elithrar 11y ago
If you're okay with OAuth providers then https://github.com/markbates/goth https://github.com/markbates/goth gives you the capability to handle more than just Google accounts.
Otherwise, you're right in that there doesn't exist a 'de facto' auth package for Go like Devise in the Rails world. Part of this is because you can't rely on stuff like ActiveRecord, ActionController, etc. to do some of the heavy lifting for you (Go being just a language, not a framework on its own).
FWIW, I'm partway through writing a concise cookie- (and optionally Redis-) backed store that effectively asks you to provide a `User` type that can satisfy `GetID() string` and `IsAdmin() bool` methods. The middleware/lib does most of the work once you call `mypkg.SetUser(yourusertype)` in your login handler.
This obviously doesn't cover features such as password reset emails, user registration, etc because you either have to make a ton of assumptions about your users' design/implementation, keep things limited, or fall into the trap of "provide options for every possible use case".
PS: Ping me via email if you want some guidance. Happy to share some code snippets and/or input as I've been down the roll-my-own path a couple of times already.
- chrisfosterelli 11y agoWill do, thanks!