Skip to content

Commit

Permalink
auth: Move signature from url to header
Browse files Browse the repository at this point in the history
Signed-off-by: shengyong002 <[email protected]>
  • Loading branch information
shengyong002 committed Dec 6, 2021
1 parent 5a4a9d8 commit 8295b08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions master/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ type FilterFunc func(signs []*proto.AuthSignature, item interface{}) AuthHandle
type ModifyFunc func(item interface{}) interface{}

func (m *Server) parseSignatures(r *http.Request) (signs []*proto.AuthSignature, err error) {
if err = r.ParseForm(); err != nil {
return
signature := r.Header.Get(signatureHeaderKey)
if signature == "" {
if err = r.ParseForm(); err != nil {
return
}
signature = r.FormValue(signatureKey)
}

signature := r.FormValue(signatureKey)
if signature == "" {
return
}
Expand Down
1 change: 1 addition & 0 deletions master/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
dpSelectorNameKey = "dpSelectorName"
dpSelectorParmKey = "dpSelectorParm"
signatureKey = "signature"
signatureHeaderKey = "X-CBFS-Signature"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion sdk/master/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (c *MasterClient) generateSignature(r *request) (err error) {
return
}

r.addParam("signature", string(signature[:]))
r.addHeader("X-CBFS-Signature", string(signature[:]))
return
}

Expand Down

0 comments on commit 8295b08

Please sign in to comment.