mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Pass context in OIDC helpers
This commit is contained in:
parent
434747e007
commit
52073ce7c9
1 changed files with 6 additions and 4 deletions
10
oidc.go
10
oidc.go
|
@ -148,12 +148,12 @@ func (h *Headscale) OIDCCallback(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rawIDToken, err := h.getIDTokenForOIDCCallback(writer, code, state)
|
rawIDToken, err := h.getIDTokenForOIDCCallback(req.Context(), writer, code, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
idToken, err := h.verifyIDTokenForOIDCCallback(writer, rawIDToken)
|
idToken, err := h.verifyIDTokenForOIDCCallback(req.Context(), writer, rawIDToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -240,10 +240,11 @@ func validateOIDCCallbackParams(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) getIDTokenForOIDCCallback(
|
func (h *Headscale) getIDTokenForOIDCCallback(
|
||||||
|
ctx context.Context,
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
code, state string,
|
code, state string,
|
||||||
) (string, error) {
|
) (string, error) {
|
||||||
oauth2Token, err := h.oauth2Config.Exchange(context.Background(), code)
|
oauth2Token, err := h.oauth2Config.Exchange(ctx, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Err(err).
|
Err(err).
|
||||||
|
@ -287,11 +288,12 @@ func (h *Headscale) getIDTokenForOIDCCallback(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) verifyIDTokenForOIDCCallback(
|
func (h *Headscale) verifyIDTokenForOIDCCallback(
|
||||||
|
ctx context.Context,
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
rawIDToken string,
|
rawIDToken string,
|
||||||
) (*oidc.IDToken, error) {
|
) (*oidc.IDToken, error) {
|
||||||
verifier := h.oidcProvider.Verifier(&oidc.Config{ClientID: h.cfg.OIDC.ClientID})
|
verifier := h.oidcProvider.Verifier(&oidc.Config{ClientID: h.cfg.OIDC.ClientID})
|
||||||
idToken, err := verifier.Verify(context.Background(), rawIDToken)
|
idToken, err := verifier.Verify(ctx, rawIDToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Err(err).
|
Err(err).
|
||||||
|
|
Loading…
Reference in a new issue