email 주소를 제대로 못읽는 문제 수정
This commit is contained in:
@ -123,7 +123,7 @@ func (caller apiCaller) getAccessableServices() ([]*serviceDescription, []string
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
email := v.(string)
|
email = v.(string)
|
||||||
_, admin = caller.admins[email]
|
_, admin = caller.admins[email]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -166,10 +166,10 @@ type maintenance struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type division struct {
|
type division struct {
|
||||||
Url string `bson:"url"`
|
Url string // 요것은 클라이언트 빌드하고 나서 json:"-"으로 변경하자. 클라이언트에 직접 내려보내지 않음
|
||||||
Priority int `bson:"priority"`
|
Priority int
|
||||||
State divisionStateName `bson:"state"`
|
State divisionStateName
|
||||||
Maintenance *maintenance `bson:"maintenance"`
|
Maintenance *maintenance `bson:",omitempty" json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceDescription struct {
|
type serviceDescription struct {
|
||||||
@ -307,9 +307,10 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
|
|
||||||
if len(sh.ApiUsers) == 0 {
|
if len(sh.ApiUsers) == 0 {
|
||||||
sh.ApiUsers = map[string][]string{
|
sh.ApiUsers = map[string][]string{
|
||||||
"service": {},
|
"service": {},
|
||||||
"whitelist": {},
|
"whitelist": {},
|
||||||
"account": {},
|
"account": {},
|
||||||
|
"maintenance": {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parsedUsers := make(map[string]map[string]bool)
|
parsedUsers := make(map[string]map[string]bool)
|
||||||
@ -329,7 +330,7 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
bt, _ := json.Marshal(sh)
|
bt, _ := json.Marshal(sh)
|
||||||
atomic.StorePointer(&sh.serviceSerialized, unsafe.Pointer(&bt))
|
atomic.StorePointer(&sh.serviceSerialized, unsafe.Pointer(&bt))
|
||||||
|
|
||||||
logger.Println("service is ready :", sh.ServiceName, sh.ServiceCode, sh.UseWhitelist, string(divmarshaled))
|
logger.Println("service is ready :", sh.ServiceName, sh.ServiceCode, sh.UseWhitelist, sh.ApiUsers, string(divmarshaled))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -472,12 +473,17 @@ func (sh *serviceDescription) isValidAPIUser(category string, email string) bool
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if users, ok := catusers[category]; ok {
|
logger.Println("isValidAPIUser failed. email is not allowed :", category, email, catusers)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if users, ok := catusers[category]; ok {
|
||||||
if _, ok := users[email]; ok {
|
if _, ok := users[email]; ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Println("isValidAPIUser failed. email is not allowed :", category, email, users)
|
logger.Println("isValidAPIUser failed. email is not allowed :", category, email, users)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Println("isValidAPIUser failed. category is missing :", category)
|
logger.Println("isValidAPIUser failed. category is missing :", category)
|
||||||
|
|||||||
@ -263,8 +263,6 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux *
|
|||||||
case "update":
|
case "update":
|
||||||
data.Service.prepare(mg)
|
data.Service.prepare(mg)
|
||||||
if old := mg.services.get(data.Service.ServiceName); old != nil {
|
if old := mg.services.get(data.Service.ServiceName); old != nil {
|
||||||
logger.Printf("service is changed : %v", data.Service)
|
|
||||||
|
|
||||||
atomic.SwapPointer(&old.divisionsSerialized, data.Service.divisionsSerialized)
|
atomic.SwapPointer(&old.divisionsSerialized, data.Service.divisionsSerialized)
|
||||||
atomic.SwapPointer(&old.apiUsers, data.Service.apiUsers)
|
atomic.SwapPointer(&old.apiUsers, data.Service.apiUsers)
|
||||||
atomic.SwapPointer(&old.serviceSerialized, data.Service.serviceSerialized)
|
atomic.SwapPointer(&old.serviceSerialized, data.Service.serviceSerialized)
|
||||||
|
|||||||
Reference in New Issue
Block a user