feat: check PKCE even when the Auth Method is not “none”.

This commit is contained in:
Ayato 2025-03-01 22:01:42 +09:00
parent 6a80712fbe
commit acfc8ad99b
No known key found for this signature in database
GPG key ID: 56E05AE09DBA012D
2 changed files with 28 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"log/slog"
"net/http"
"os"
"strconv"
"strings"
"sync/atomic"
"time"
@ -33,6 +34,10 @@ func main() {
port := os.Getenv("PORT")
scopes := strings.Split(os.Getenv("SCOPES"), " ")
responseMode := os.Getenv("RESPONSE_MODE")
pkce, err := strconv.ParseBool(os.Getenv("PKCE"))
if err != nil {
logrus.Fatalf("error parsing PKCE %s", err.Error())
}
redirectURI := fmt.Sprintf("http://localhost:%v%v", port, callbackPath)
cookieHandler := httphelper.NewCookieHandler(key, key, httphelper.WithUnsecure())
@ -64,6 +69,9 @@ func main() {
if keyPath != "" {
options = append(options, rp.WithJWTProfile(rp.SignerFromKeyPath(keyPath)))
}
if pkce {
options = append(options, rp.WithPKCE(cookieHandler))
}
// One can add a logger to the context,
// pre-defining log attributes as required.