-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Description
Current basic auth flow - is it a password? is it a password again? is it a token?
In the current implementation, when cloning/committing private repo over http/https using basic auth header, for each request, Gitea tries the following workflow
-
treating basic auth token as password and attempting to sign in user when creating context in middleware (modules/context/context.go).
-
treating basic auth token as password and attempting to sign in user AGAIN in routers/repo/http.go
-
validating it as token and verifying access to repo.
Each sign in operation involves hashing provided token and comparing it with the record retrieved from db. These are two wasted cycles in each request to perform git operations on private repo over http/https.
The proposed basic auth workflow - is it a token? is it a password?
If basic auth header is present, in context middleware, we will first attempt to validate the header as application token, then treat it as password. we can set a flag in ctx.Data to indicate whether it is plain text password. The decision can be made in routers whether to accept/reject auth by plain text password using the current logic.
If a valid token is provided (for example when Drone clones a private repo using token from a netrc file), then there will only be one validation cycle needed.
The reason behind is that there are potentially more git operations over http than login requests from users.
In order to keep existing integration with Drone, we will look for token both in username and password, using the same logic as it is done now.
Are there any concerns to this approach?