Skip to content

Commit b87bc25

Browse files
backend: Add handleOIDCCallback function
Signed-off-by: SinghaAnirban005 <[email protected]>
1 parent 848e5c5 commit b87bc25

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

backend/cmd/headlamp.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,28 @@ func setupOIDCRoutes(router *mux.Router, config *HeadlampConfig) {
543543
})
544544
}
545545

546+
func handleOIDCCallback(
547+
config *HeadlampConfig,
548+
w http.ResponseWriter,
549+
r *http.Request,
550+
oauthRequestMap map[string]*OauthConfig,
551+
) {
552+
state := r.URL.Query().Get("state")
553+
554+
if err := validateState(state); err != nil {
555+
writeOIDCError(w, err, "invalid state")
556+
return
557+
}
558+
559+
oauthConfig := getOAuthConfigFromState(state, oauthRequestMap)
560+
if oauthConfig == nil {
561+
writeOIDCError(w, nil, "invalid request")
562+
return
563+
}
564+
565+
processOIDCCallback(config, w, r, oauthConfig, state)
566+
}
567+
546568
func handleOIDC(
547569
config *HeadlampConfig,
548570
w http.ResponseWriter,

0 commit comments

Comments
 (0)