disq opened a new pull request, #1989:
URL: https://github.com/apache/tinkerpop/pull/1989

   This creates an `AuthInfoProvider` interface with the methods necessary to 
read credential/header information, changes the `AuthInfo` signature slightly 
to satisfy that interface, and updates call sites so that each call site calls 
the necessary interface method to re-read the credentials.
   
   The interface looks like:
   ```go
   type AuthInfoProvider interface {
        GetHeader() http.Header
        GetBasicAuth() (ok bool, username, password string)
   }
   ```
   
   It also adds a new `NewDynamicAuth(f func() AuthInfoProvider)` helper 
function that creates a generator based `AuthInfoProvider`, so that each time 
`GetHeader()` or `GetBasicAuth()` methods are called the given function is 
called to get a brand new `AuthInfoProvider` (which itself can be `AuthInfo` or 
something else) and the results are relayed to the caller.
   
   With this, `AuthInfo`-related constructors (`BasicAuthInfo()` and 
`HeaderAuthInfo()`) are unchanged, but there's now the ability to have any 
object provide the values (implementing `AuthInfoProvider`) and they are called 
on-demand for each connection attempt, as opposed to having them as static 
values.
   
   Note: This is my first contribution, and I couldn't get the local 
gremlin-server to play nicely to get the tests to run, but I've tried it 
elsewhere with AWS Neptune auth, like so:
   
   ```go
   // ... code to set up aws-sdk-v2 credential chain ...
                signer := v4.NewSigner()
   
                gen := func() gremlingo.AuthInfoProvider {
                        if err := signer.SignHTTP(ctx, cr, req, 
emptyStringSHA256, "neptune-db", "us-east-1", time.Now()); err != nil {
                                panic(err) // not ideal, but it's always nil
                        }
                        return gremlingo.HeaderAuthInfo(req.Header)
                }
                return gremlingo.NewDynamicAuth(gen), nil
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to