code refactoring

This commit is contained in:
2024-07-23 19:23:51 +02:00
parent ed437ec367
commit 31e3cfab24
2 changed files with 32 additions and 25 deletions

View File

@@ -1,7 +1,6 @@
package openid
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -10,7 +9,6 @@ import (
"github.com/coreos/go-oidc"
"github.com/google/uuid"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
"golang.org/x/oauth2"
)
@@ -25,29 +23,6 @@ var (
verifier *oidc.IDTokenVerifier
)
func Configure() {
if !config.Instance().UseOpenId {
return
}
provider, err := oidc.NewProvider(context.Background(), config.Instance().OpenIdProviderURL)
if err != nil {
panic(err)
}
oauth2Config = oauth2.Config{
ClientID: config.Instance().OpenIdClientId,
ClientSecret: config.Instance().OpenIdClientSecret,
RedirectURL: config.Instance().OpenIdRedirectURL,
Endpoint: provider.Endpoint(),
Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
}
verifier = provider.Verifier(&oidc.Config{
ClientID: config.Instance().OpenIdClientId,
})
}
func Login(w http.ResponseWriter, r *http.Request) {
var (
state = uuid.NewString()