new provider generation
This commit is contained in:
+23
-9
@@ -7,18 +7,27 @@ import (
|
|||||||
"golang.org/x/oauth2"
|
"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()
|
ctx := context.Background()
|
||||||
|
provider, err := oidc.NewProvider(ctx, issuer)
|
||||||
provider, err := oidc.NewProvider(ctx, "https://account.astraltech.xyz/application/o/stalwart/")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
oauthConfig := oauth2.Config{
|
OAuthConfig := oauth2.Config{
|
||||||
ClientID: "stalwart-webui",
|
ClientID: clientID,
|
||||||
RedirectURL: "http://localhost:8080/callback",
|
RedirectURL: "http://localhost:8080/callback",
|
||||||
Endpoint: provider.Endpoint(),
|
Endpoint: provider.Endpoint(),
|
||||||
Scopes: []string{
|
Scopes: []string{
|
||||||
@@ -27,6 +36,11 @@ func CreateTestOAuth() {
|
|||||||
"email",
|
"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