-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve authentication #15
Comments
Good points. We'd have to add a check on each of [ReadDir, Stat, et. al.]. Maybe add a function to do the checking, initialize auth, and call the calling function again, passed as a parameter? With this approach there will be more code that unnecessarily runs twice. |
If I correctly understand you, @chuckwagoncomputing , you suggest to add a check on each of [ReadDir, Stat, etc] functions? What do you think about it? |
From the standpoint of "seperation of concerns", that's essentially what I've done. @chripo's suggestion is that the checking should be the job of the Client part of the library, rather than the Requests part. |
Thanks for explanation. Unfortunately I have no ideas how we can deal with this. |
Further complicating this is the approach I created of duplicating the body in case it needs to be used again. I am ashamed of what I have done but I'm not sure how else to do it. If we do some redesigning, both of these things need to be considered. |
@chripo , to remove |
From my point of view, sending the body twice is a total waste of performance and time. I think there is a way to send the first 6request without a body, need time for a deeper look into the specs / rfcs. |
I haven't actually read the RFCs, but I know some clients do not send the body the first time. SabreDAV has a bug and won't authenticate with an empty body. The maintainer refused to fix it because he claimed it was non-standard to send the first packet without a body. It does have a workaround though. |
I read RFCs, and this things is important for us:
rs, err := c.req("PROPFIND", path, strings.NewReader(body), func(rq *http.Request) {
if self {
rq.Header.Add("Depth", "0")
} else {
rq.Header.Add("Depth", "1")
}
rq.Header.Add("Content-Type", "text/xml;charset=UTF-8")
rq.Header.Add("Accept", "application/xml,text/xml")
rq.Header.Add("Accept-Charset", "utf-8")
// TODO add support for 'gzip,deflate;q=0.8,q=0.7'
rq.Header.Add("Accept-Encoding", "")
}) because
I propose to create
|
@chripo, have you got anywhere with this? |
@MrVine wrote:
That makes no sense for a client library. The RFC states that servers must not present a Basic challenge, unless they're served over a secure connection (ie - TLS). I'd suggest that Basic auth is very widely implemented, as generally connections will be TLS encrypted. I'd be very concerned about any authentication over insecure channels, as leaking bearer tokens or other form of auth is frequently just as bad as leaking a username/password. In fact, Basic auth must be supported, for servers that only support it, and it's likely the only globally supported mechanism.
I see very little value in complicating the auth mechanism in this direction, based on the above, and also based on the caveats listed in the RFC. |
The main goal was to simplify the `req` method in `request.go` and making it easier to add more authentication methods. All the magic went into the `auth.go` file. This feature introduces an `Authorizer` which acts as an `Authenticator` factory. Under the hood it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The authentication flow itself is broken down into `Authorize' and `Verify' steps to encapsulate and control complex authentication challenges. Furthermore, the default `NewAutoAuth' authenticator can be overridden by a custom implementation for more control over flow and resources. The `NewBacisAuth` Authorizer gives us the feel of the old days.
The main goal was to simplify the `req` method in `request.go` and making it easier to add more authentication methods. All the magic went into the `auth.go` file. This feature introduces an `Authorizer` which acts as an `Authenticator` factory. Under the hood it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The authentication flow itself is broken down into `Authorize' and `Verify' steps to encapsulate and control complex authentication challenges. Furthermore, the default `NewAutoAuth' authenticator can be overridden by a custom implementation for more control over flow and resources. The `NewBacisAuth` Authorizer gives us the feel of the old days.
The main goal was to simplify the `req` method in `request.go` and making it easier to add more authentication methods. All the magic went into the `auth.go` file. This feature introduces an `Authorizer` which acts as an `Authenticator` factory. Under the hood it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The authentication flow itself is broken down into `Authorize' and `Verify' steps to encapsulate and control complex authentication challenges. Furthermore, the default `NewAutoAuth` authenticator can be overridden by a custom implementation for more control over flow and resources. The `NewBacisAuth` Authorizer gives us the feel of the old days.
The main goal was to simplify the `req` method in `request.go` and making it easier to add more authentication methods. All the magic went into the `auth.go` file. This feature introduces an `Authorizer` which acts as an `Authenticator` factory. Under the hood it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The authentication flow itself is broken down into `Authorize` and `Verify' steps to encapsulate and control complex authentication challenges. Furthermore, the default `NewAutoAuth` authenticator can be overridden by a custom implementation for more control over flow and resources. The `NewBacisAuth` Authorizer gives us the feel of the old days.
The main goal was to simplify the `req` method in `request.go` and making it easier to add more authentication methods. All the magic went into the `auth.go` file. This feature introduces an `Authorizer` which acts as an `Authenticator` factory. Under the hood it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The authentication flow itself is broken down into `Authorize` and `Verify' steps to encapsulate and control complex authentication challenges. Furthermore, the default `NewAutoAuth` authenticator can be overridden by a custom implementation for more control over flow and resources. The `NewBacisAuth` Authorizer gives us the feel of the old days.
The changes simplify the `req` method by moving the authentication-related code into the API. This makes it easy to add additional authentication methods. The API introduces an `Authorizer` that acts as an authenticator factory. The authentication flow itself is divided down into `Authorize` and `Verify` steps in order to encapsulate and control complex authentication challenges. The default `NewAutoAuth` negotiates the algorithms. Under the hood, it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The `NewEmptyAuth` and `NewPreemptiveAuth` authorizers allow you to have more control over algorithms and resources. The API also allows interception of the redirect mechanism by setting the `XInhibitRedirect` header. This closes: #15 #24 #38
The changes simplify the `req` method by moving the authentication-related code into the API. This makes it easy to add additional authentication methods. The API introduces an `Authorizer` that acts as an authenticator factory. The authentication flow itself is divided down into `Authorize` and `Verify` steps in order to encapsulate and control complex authentication challenges. The default `NewAutoAuth` negotiates the algorithms. Under the hood, it creates an authenticator shim per request, which delegates the authentication flow to our authenticators. The `NewEmptyAuth` and `NewPreemptiveAuth` authorizers allow you to have more control over algorithms and resources. The API also allows interception of the redirect mechanism by setting the `XInhibitRedirect` header. This closes: #15 #24 #38
fix #14 in commit b45378c changed the behaviour of the
req()
method. the auth checks were moved fromConnect()
toreq()
.how to improve the code to keep the modification inside the client, because it's a client improvement and to keep the request as small as possible.
suggestions and discussion are welcome!
The text was updated successfully, but these errors were encountered: