new provider generation

This commit is contained in:
2026-08-06 20:17:22 -04:00
parent e6cebed4ba
commit fd12ba02fd
+23 -9
View File
@@ -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
} }