Coder Social home page Coder Social logo

digest's People

Contributors

bobziuchkovski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

digest's Issues

Re-Use challenge

The RFC states that a challenge can be re-used for more than one request. This let's you avoid making 2 round-trips for every request. The transport implementation doesn't do that.

cookie handling

There is no cookie handling in the RoundTrip function for the cookies possibly returned by the first request

400 Bad Request for http PATCH call with digest authentication

func httpCall(method, uri string, payload []byte) (*http.Response, error){

   data, err := json.Marshal(map[string]interface{}{
	"password": "123456",
})

t := digest.NewTransport(config.Mongo.PublicKey, config.Mongo.PrivateKey)
   req, err := http.NewRequest(method, uri, bytes.NewReader(data))
req.Header.Set("Content-Type", "application/json")
res, err := t.RoundTrip(req)
log.Printf("%+v", res)
return res, err

}

PATCH Request Throws 400 Bad Request, But the same function works for GET method

I am trying to hit MongoDB Update User API to change password i.e. https://www.mongodb.com/docs/atlas/reference/api/database-users-update-a-user/

{Status:400 Bad Request StatusCode:400 Proto:HTTP/2.0 ProtoMajor:2 ProtoMinor:0 Header:map[Content-Length:[185] Content-Type:[application/json] Date:[Wed, 13 Apr 2022 00:19:19 GMT] Referrer-Policy:[strict-origin-when-cross-origin] Server:[envoy] Strict-Transport-Security:[max-age=31536000; includeSubdomains;] X-Content-Type-Options:[nosniff] X-Envoy-Upstream-Service-Time:[39] X-Frame-Options:[DENY] X-Mongodb-Service-Version:[gitHash=313eecc3b1fc39a689953c7a77f3ea15380e088e; versionString=v20220330] X-Permitted-Cross-Domain-Policies:[none]] Body:{cs:0xc0003ad800} ContentLength:185 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc000564c00 TLS:0xc0002aee70}

Bug: http post with body

There is a bug with this library. If you use the wrapper to send http post with body (eg. json) you will get a "ContentLeng=... with Body length is 0" error. The reason being "body" in http.request object is io.reader, it is being read once when doing authentication and is depleted. When the actual request is sent to server after authenticated, the buffer is already drained and is empty, thus the length 0 error. I find this post particular useful , it fixes the bug:
https://stackoverflow.com/questions/23070876/reading-body-of-http-request-without-modifying-request-state

parseChallenge erroring out with Digest "charset" set

If the Digest contains a "charset" directive, (or anything not covered by the switch statement) it will throw a ErrBadChallenge Error. ("Challenge is bad").

One can add the additional cases into the switch to solve this of course, but for anyone wondering why the error appears...

Should not split on ", "

Not sure what it says in the specification but the server I'm calling does not use whitespaces between params in the challenge. I.e. when splitting on comma plus whitespace it won't work.

My suggestion would be to split on comma (",") ONLY and then trim the individual parts.

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.