Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oauth APPs for users #8

Open
moos3 opened this issue Jul 29, 2019 · 3 comments
Open

Oauth APPs for users #8

moos3 opened this issue Jul 29, 2019 · 3 comments

Comments

@moos3
Copy link

moos3 commented Jul 29, 2019

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 ?

@LyricTian
Copy link
Member

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,
	}))
}

@moos3
Copy link
Author

moos3 commented Sep 3, 2019

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
}

@jarlandre
Copy link

jarlandre commented Jan 18, 2023

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 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants