Skip to content

Commit

Permalink
Add origin flag to allow to set a custom Origin header
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji97 committed Jun 26, 2023
1 parent a00c457 commit c5a1d39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func NewOAuth2Cmd() (cmd *OAuth2Cmd) {
cmd.PersistentFlags().BoolVarP(&silent, "silent", "s", false, "silent mode")
cmd.PersistentFlags().BoolVar(&cconfig.DPoP, "dpop", false, "use DPoP")
cmd.PersistentFlags().StringVar(&cconfig.Claims, "claims", "", "claims parameter")
cmd.PersistentFlags().StringVar(&cconfig.Origin, "origin", "", "origin header")

return cmd
}
Expand Down
5 changes: 5 additions & 0 deletions internal/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type ClientConfig struct {
Timeout time.Duration
DPoP bool
Claims string
Origin string
}

func RequestAuthorization(cconfig ClientConfig, sconfig ServerConfig, hc *http.Client) (r Request, codeVerifier string, err error) {
Expand Down Expand Up @@ -437,6 +438,10 @@ func RequestToken(

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

if cconfig.Origin != "" {
req.Header.Add("Origin", cconfig.Origin)
}

if cconfig.DPoP {
if err = DPoPSignRequest(cconfig.SigningKey, hc, req); err != nil {
return request, response, err
Expand Down

0 comments on commit c5a1d39

Please sign in to comment.