Skip to content

Commit

Permalink
Merge pull request #126 from avalanche123/fix-websocket-init
Browse files Browse the repository at this point in the history
skip websocket auth init if initialized
  • Loading branch information
avalanche123 authored Sep 20, 2023
2 parents 7c1b213 + a28bc4b commit b9fde41
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func Middleware(next http.Handler) http.Handler {
}

func WebsocketInit(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) {
// don't re-initialize credentials from the init payload if present in request headers.
if cr, ok := FromContext(ctx); ok {
if cr.BasicUsername != "" || cr.BasicPassword != "" || cr.BearerToken != "" ||
cr.Impersonate.Username != "" || len(cr.Impersonate.Groups) > 0 || len(cr.Impersonate.Extra) > 0 {
return ctx, nil
}
}
r := &http.Request{
Header: make(http.Header),
}
Expand Down

0 comments on commit b9fde41

Please sign in to comment.