Skip to content

Commit

Permalink
skip websocket auth init if initialized
Browse files Browse the repository at this point in the history
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
  • Loading branch information
avalanche123 committed Sep 20, 2023
1 parent 7c1b213 commit a28bc4b
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 a28bc4b

Please sign in to comment.