-
Notifications
You must be signed in to change notification settings - Fork 534
Add AuthMethod based on HTTP Authorization header #504
Conversation
Codecov Report
@@ Coverage Diff @@
## v4 #504 +/- ##
==========================================
- Coverage 78.12% 77.42% -0.71%
==========================================
Files 127 127
Lines 9313 9323 +10
==========================================
- Hits 7276 7218 -58
- Misses 1241 1324 +83
+ Partials 796 781 -15
Continue to review full report at Codecov.
|
@strin looks like your PRs are being mixed because you are using the same branch, can you take care of this? |
return | ||
} | ||
|
||
r.Header.Set("Authorization", a.token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be Bearer requires the format: " Authorization: Bearer %s"
} | ||
|
||
// NewTokenAuth returns a tokenAuth on the given authrorization token. | ||
func NewTokenAuth(token string) *TokenAuth { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be called it NewBearerAuth
?
} | ||
|
||
func (a *TokenAuth) String() string { | ||
return fmt.Sprintf("%s...", a.token[:10]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token should be cloaked, otherwise the security can be compromised.
This allows us to use
Authorization: Bearer XXXXX
to authenticate Git HTTP requests.