Giter Site home page Giter Site logo

Comments (2)

odannyc avatar odannyc commented on May 31, 2024

After more digging of the code I found this:

cloudinary-go/api/api.go

Lines 211 to 224 in 320ac57

func SignParameters(params url.Values, secret string) (string, error) {
params.Set("timestamp", strconv.FormatInt(time.Now().Unix(), 10))
encodedUnescapedParams, err := url.QueryUnescape(params.Encode())
if err != nil {
return "", err
}
rawSignature, err := signature.Sign(encodedUnescapedParams, secret, signature.SHA1)
if err != nil {
return "", err
}
return hex.EncodeToString(rawSignature), nil
}

Can I simply return that string to the frontend for them to use on a signed upload request?

from cloudinary-go.

igy avatar igy commented on May 31, 2024

Hi Danny,

Yes, the output from that function should be a valid signature for a signed upload, and passing the signature string from the backend to the frontend is the same method we recommend for similar cases, like using our Javascript Upload Widget with signed upload where the signature comes from some backend code.

That said, the parameters sent on the API call must match the parameters used to create the signature, and the highlighted function is also setting the timestamp that's used on the request, so you need to pass the same timestamp to your frontend also and use it on the API call ( e.g.

requestParams.Set("timestamp", signatureParams.Get("timestamp"))
where the timestamp used in teh signing function is added to the API call)

If there's any problem with the signature you send on an API call, note that our error response shows the string we signed when checking the provided signature, so it's often easy to see why the signature didn't match

Thanks,
Stephen

from cloudinary-go.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.