mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Merge branch 'master' into mew-catch-all-v2
This commit is contained in:
commit
cb7fde2f86
2
auth.go
2
auth.go
@ -47,7 +47,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
|
|||||||
pairs := processAccounts(accounts)
|
pairs := processAccounts(accounts)
|
||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
// Search user in the slice of allowed credentials
|
// Search user in the slice of allowed credentials
|
||||||
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
|
user, found := pairs.searchCredential(c.requestHeader("Authorization"))
|
||||||
if !found {
|
if !found {
|
||||||
// Credentials doesn't match, we return 401 and abort handlers chain.
|
// Credentials doesn't match, we return 401 and abort handlers chain.
|
||||||
c.Header("WWW-Authenticate", realm)
|
c.Header("WWW-Authenticate", realm)
|
||||||
|
@ -509,7 +509,7 @@ func (c *Context) ClientIP() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.engine.AppEngine {
|
if c.engine.AppEngine {
|
||||||
if addr := c.Request.Header.Get("X-Appengine-Remote-Addr"); addr != "" {
|
if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user