mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
use the new protobuf package and other minor stuff
Former-commit-id: 29bf71e8a73d34b27c6f5fe3f12c4ea1cc2b84b2
This commit is contained in:
@@ -23,7 +23,7 @@ type (
|
||||
logged bool
|
||||
expires time.Time
|
||||
}
|
||||
encodedUsers []encodedUser
|
||||
encodedUsers []*encodedUser
|
||||
|
||||
basicAuthMiddleware struct {
|
||||
config Config
|
||||
@@ -75,7 +75,7 @@ func (b *basicAuthMiddleware) init() {
|
||||
for k, v := range b.config.Users {
|
||||
fullUser := k + ":" + v
|
||||
header := "Basic " + base64.StdEncoding.EncodeToString([]byte(fullUser))
|
||||
b.auth = append(b.auth, encodedUser{HeaderValue: header, Username: k, logged: false, expires: DefaultExpireTime})
|
||||
b.auth = append(b.auth, &encodedUser{HeaderValue: header, Username: k, logged: false, expires: DefaultExpireTime})
|
||||
}
|
||||
|
||||
// set the auth realm header's value
|
||||
@@ -85,20 +85,16 @@ func (b *basicAuthMiddleware) init() {
|
||||
b.askHandlerEnabled = b.config.OnAsk != nil
|
||||
}
|
||||
|
||||
func (b *basicAuthMiddleware) findAuth(headerValue string) (auth *encodedUser, found bool) {
|
||||
if len(headerValue) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, user := range b.auth {
|
||||
if user.HeaderValue == headerValue {
|
||||
auth = &user
|
||||
found = true
|
||||
break
|
||||
func (b *basicAuthMiddleware) findAuth(headerValue string) (*encodedUser, bool) {
|
||||
if headerValue != "" {
|
||||
for _, user := range b.auth {
|
||||
if user.HeaderValue == headerValue {
|
||||
return user, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (b *basicAuthMiddleware) askForCredentials(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user