new provider generation
This commit is contained in:
+23
-9
@@ -7,18 +7,27 @@ import (
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
var OAuthConfigs []oauth2.Config
|
||||
// This is all the user info that this script needs
|
||||
type UserInfo struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func CreateTestOAuth() {
|
||||
type OAuthProvider struct {
|
||||
Provider *oidc.Provider
|
||||
Config oauth2.Config
|
||||
}
|
||||
|
||||
var Providers []OAuthProvider
|
||||
|
||||
func CreateOAuthProvider(issuer string, clientID string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
provider, err := oidc.NewProvider(ctx, "https://account.astraltech.xyz/application/o/stalwart/")
|
||||
provider, err := oidc.NewProvider(ctx, issuer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
|
||||
oauthConfig := oauth2.Config{
|
||||
ClientID: "stalwart-webui",
|
||||
OAuthConfig := oauth2.Config{
|
||||
ClientID: clientID,
|
||||
RedirectURL: "http://localhost:8080/callback",
|
||||
Endpoint: provider.Endpoint(),
|
||||
Scopes: []string{
|
||||
@@ -27,6 +36,11 @@ func CreateTestOAuth() {
|
||||
"email",
|
||||
},
|
||||
}
|
||||
OAuthConfigs = append(OAuthConfigs, oauthConfig)
|
||||
TestTokenStore = TokenStore{filePath: "token.json"}
|
||||
|
||||
newProvider := OAuthProvider{
|
||||
Provider: provider,
|
||||
Config: OAuthConfig,
|
||||
}
|
||||
Providers = append(Providers, newProvider)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user