0
0
mirror of https://github.com/vx3r/wg-gen-web.git synced 2024-11-04 17:31:17 +00:00
wg-gen-web/auth/fake/fake.go

49 lines
1.0 KiB
Go
Raw Normal View History

2020-04-28 11:11:49 +00:00
package fake
import (
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
"golang.org/x/oauth2"
"time"
)
2020-06-10 07:52:44 +00:00
// Fake in order to implement interface, struct is required
2020-04-28 11:11:49 +00:00
type Fake struct{}
// Setup validate provider
func (o *Fake) Setup() error {
return nil
}
// CodeUrl get url to redirect client for auth
func (o *Fake) CodeUrl(state string) string {
return "_magic_string_fake_auth_no_redirect_"
}
// Exchange exchange code for Oauth2 token
func (o *Fake) Exchange(code string) (*oauth2.Token, error) {
rand, err := util.GenerateRandomString(32)
if err != nil {
return nil, err
}
return &oauth2.Token{
AccessToken: rand,
TokenType: "",
RefreshToken: "",
Expiry: time.Time{},
}, nil
}
// UserInfo get token user
func (o *Fake) UserInfo(oauth2Token *oauth2.Token) (*model.User, error) {
return &model.User{
Sub: "unknown",
Name: "Unknown",
Email: "unknown",
Profile: "unknown",
Issuer: "unknown",
IssuedAt: time.Time{},
}, nil
}