facebookarchive / flashback

Capture and replay real mongodb workloads
Other
217 stars 72 forks source link

Authenticate flashback sessions if user/pass provided in url #45

Closed timvaillancourt closed 7 years ago

timvaillancourt commented 7 years ago

This a much-simplified version of #25, the main difference is I am using mgo's builtin ParseURL function instead of string parsing stuff myself: https://godoc.org/gopkg.in/mgo.v2#ParseURL.

The mongodb url+credentials are provided via the format (has to start with mongodb:// for mgo.ParseURL to parse it):

mongodb://<user>:<password>@host:port/database

The "-url" parameter was lightly modified to support/explain this:

  -url string
        [Optional] The database server's url, in the format of mongodb://[<user>:<password>@]<host>[:<port>]. Defaults to mongodb://localhost:27017

So if you wanted to auth as 'tim' and password '123456', here is what your -url flag would look like:

flashback -url mongodb://tim:123456@localhost:27017 ...

If auth is enabled on a server but no credentials are provided, flashback will die with "not authorized to execute op" errors.

timvaillancourt commented 7 years ago

I made a few 'cleanup' fixes I should have done before submitting. I'm done tweaking this now and this is the final set of changes for this PR.

tredman commented 7 years ago

lgtm. thanks!