Oauth APPs for users
So I'm working on an authentication system for users. I want to allow my users to create OAuth apps sorta like how GitHub does it in their developer section. Where the user can create the application, with register they get the client id and client secret. So I have functionality that will generate a client id and client secret with refresh/ revoke. What I'm wondering is how to take your example and make it database driven. Could you provide some guidance ?
You can refer to the use of redis storage: https://github.com/go-oauth2/redis
package main
import (
"gopkg.in/go-oauth2/redis.v3"
"gopkg.in/oauth2.v3/manage"
)
func main() {
manager := manage.NewDefaultManager()
// use redis token store
manager.MapTokenStorage(redis.NewRedisStore(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 15,
}))
}
We have currently a struct like this, this allow a user to create a new application to allow them to leverage our api. In our legacy PHP application, ClientID and ClientSecret are generated for the user.
type App struct {
ID uuid.UUID
Name string
Slug string
Description string
ClientID string
ClientSecret string
CallbackURL string
AppURL string
}
https://github.com/vgarvardt/go-oauth2-pg for ex. But you can also just implement the interfaces yourself too. With your own database logic. e.g.
ClientStore interface {
TokenStore interface {