...
1 package verify
2
3 import (
4 "net/http"
5
6 "edge-infra.dev/pkg/edge/iam/log"
7
8 "github.com/coreos/go-oidc/v3/oidc"
9 "github.com/gin-gonic/gin"
10 "golang.org/x/oauth2"
11 )
12
13 func (v *Verifier) start(ctx *gin.Context) {
14 log := log.Get(ctx.Request.Context())
15
16 provider, err := oidc.NewProvider(oidc.InsecureIssuerURLContext(ctx, Issuer()), IssuerURL())
17 if err != nil {
18 err := ctx.AbortWithError(http.StatusInternalServerError, err)
19 if err != nil {
20 log.Error(err, "failed to abort with error")
21 }
22 return
23 }
24
25 config := oauth2.Config{
26 ClientID: v.ClientID,
27 ClientSecret: v.ClientSecret,
28 RedirectURL: v.ClientURL + verifyCallbackPath,
29 Endpoint: provider.Endpoint(),
30 Scopes: []string{oidc.ScopeOpenID, oidc.ScopeOfflineAccess, "profile"},
31 }
32
33 loginHint := ctx.Request.URL.Query().Get("login_hint")
34 authCodeURL := config.AuthCodeURL("332b7b6ue34ds", oauth2.SetAuthURLParam("login_hint", loginHint))
35
36 ctx.Redirect(http.StatusFound, authCodeURL)
37 }
38
View as plain text