Skip to content

Commit e577435

Browse files
Merge pull request #1521 from 0chain/fix/restricted-expiry
Fix/restricted expiry
2 parents 1bd2c18 + 3f32c14 commit e577435

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

code/go/0chain.net/blobbercore/handler/auth_ticket.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package handler
22

33
import (
44
"context"
5+
"fmt"
56
"github.com/0chain/blobber/code/go/0chain.net/core/node"
67
"github.com/0chain/common/core/common"
78
"net/http"
@@ -19,24 +20,27 @@ type AuthTicketResponse struct {
1920
//
2021
// parameters:
2122
//
22-
// +name: Zbox-Signature
23-
// in: header
24-
// type: string
25-
// description: Digital signature to verify that the sender is 0box service.
26-
// +name: client_id
27-
// type: string
28-
// in: query
29-
// description: Client ID is used as a payload to the token generated. The token represents a signed version of this string by the blobber's private key.
23+
// +name: Zbox-Signature
24+
// in: header
25+
// type: string
26+
// description: Digital signature to verify that the sender is 0box service.
27+
// +name: client_id
28+
// type: string
29+
// in: query
30+
// description: Client ID is used as a payload to the token generated. The token represents a signed version of this string by the blobber's private key.
3031
//
3132
// responses:
32-
// 200: AuthTicketResponse
33+
//
34+
// 200: AuthTicketResponse
3335
func GenerateAuthTicket(ctx context.Context, r *http.Request) (interface{}, error) {
3436
clientID := r.URL.Query().Get("client_id")
3537
if clientID == "" {
3638
return nil, common.NewError("missing_client_id", "client_id is required")
3739
}
3840

39-
signature, err := node.Self.Sign(clientID)
41+
round := r.URL.Query().Get("round")
42+
43+
signature, err := node.Self.Sign(fmt.Sprintf("%s_%s", clientID, round))
4044
if err != nil {
4145
return nil, common.NewError("signature_failed", "signature failed")
4246
}

0 commit comments

Comments
 (0)