2020-04-28 11:11:49 +00:00
|
|
|
package fake
|
|
|
|
|
|
|
|
import (
|
2021-04-06 12:23:23 +00:00
|
|
|
"github.com/vx3r/wg-gen-web/model"
|
|
|
|
"github.com/vx3r/wg-gen-web/util"
|
2020-04-28 11:11:49 +00:00
|
|
|
"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
|
|
|
|
}
|