Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion code/go/0chain.net/blobbercore/handler/auth_ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
"github.com/0chain/blobber/code/go/0chain.net/core/node"
"github.com/0chain/common/core/common"
"github.com/0chain/gosdk/zcncore"
"net/http"
)

Expand Down Expand Up @@ -34,14 +35,21 @@ type AuthTicketResponse struct {
//
// 200: AuthTicketResponse
func GenerateAuthTicket(ctx context.Context, r *http.Request) (interface{}, error) {

clientID := r.URL.Query().Get("client_id")
if clientID == "" {
return nil, common.NewError("missing_client_id", "client_id is required")
}

round := r.URL.Query().Get("round")

signature, err := node.Self.Sign(encryption.Hash(fmt.Sprintf("%s_%s", clientID, round)))
payload := encryption.Hash(fmt.Sprintf("%s_%s", clientID, round))

if isActivated, err := zcncore.IsHardforkActivated("hermes"); err != nil || !isActivated {
payload = clientID
}

signature, err := node.Self.Sign(payload)
if err != nil {
return nil, common.NewError("signature_failed", "signature failed")
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.5

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.18.15
github.com/0chain/gosdk v1.18.18-0.20250106145917-0f4cb303af5c
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/didip/tollbooth/v6 v6.1.2
github.com/go-openapi/runtime v0.26.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI=
github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.18.15 h1:jujBBRAv2xendebjdoC6nMmoVl5w+uhDrKBqokIvxKI=
github.com/0chain/gosdk v1.18.15/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
github.com/0chain/gosdk v1.18.18-0.20250106145917-0f4cb303af5c h1:OhtnsZKkWJpUzzDJdsPpBeOv5qhksPbQ1QL2exxsQgY=
github.com/0chain/gosdk v1.18.18-0.20250106145917-0f4cb303af5c/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
Expand Down
Loading