Skip to content

Commit

Permalink
Send x-forwarded-for in Okta Push Factor request
Browse files Browse the repository at this point in the history
Why:

In order for Okta to properly report the location of the authentication
attempt, the X-Forwarded-For header must be included in the request to
Okta (if it exists).

This change addresses the need by:

* Duplicating the value of X-Forwarded-For if it's passed through to the
  auth backend
  • Loading branch information
rbhitchcock committed Aug 13, 2021
1 parent b6ffe28 commit dddc816
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions builtin/credential/okta/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package okta
import (
"context"
"fmt"
"net/textproto"
"time"

"github.com/hashicorp/vault/helper/mfa"
Expand Down Expand Up @@ -216,6 +217,9 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username, pas
if err != nil {
return nil, nil, nil, err
}
if len(req.Headers["X-Forwarded-For"]) > 0 {
verifyReq.Header.Set("X-Forwarded-For", req.Headers[textproto.CanonicalMIMEHeaderKey("X-Forwarded-For")][0])
}

rsp, err := shim.Do(verifyReq, &result)
if err != nil {
Expand Down

0 comments on commit dddc816

Please sign in to comment.