whitelist를 mg로 이동
This commit is contained in:
@ -175,8 +175,10 @@ type Maingate struct {
|
|||||||
|
|
||||||
auths *common.AuthCollection
|
auths *common.AuthCollection
|
||||||
//services servicelist
|
//services servicelist
|
||||||
serviceptr unsafe.Pointer
|
serviceptr unsafe.Pointer
|
||||||
admins unsafe.Pointer
|
admins unsafe.Pointer
|
||||||
|
wl whitelist
|
||||||
|
|
||||||
tokenEndpoints map[string]string
|
tokenEndpoints map[string]string
|
||||||
authorizationEndpoints map[string]string
|
authorizationEndpoints map[string]string
|
||||||
userinfoEndpoint map[string]string
|
userinfoEndpoint map[string]string
|
||||||
@ -422,6 +424,12 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var whites []whitelistmember
|
||||||
|
if err := mg.mongoClient.AllAs(CollectionWhitelist, &whites, options.Find().SetReturnKey(false)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mg.wl.init(whites)
|
||||||
|
|
||||||
go watchAuthCollection(context, mg.auths, mg.mongoClient)
|
go watchAuthCollection(context, mg.auths, mg.mongoClient)
|
||||||
go mg.watchWhitelistCollection(context)
|
go mg.watchWhitelistCollection(context)
|
||||||
|
|
||||||
|
|||||||
@ -139,7 +139,7 @@ type serviceDescription struct {
|
|||||||
Admins []string `bson:"admins" json:"admins"`
|
Admins []string `bson:"admins" json:"admins"`
|
||||||
|
|
||||||
auths *common.AuthCollection
|
auths *common.AuthCollection
|
||||||
wl whitelist
|
wl *whitelist
|
||||||
mongoClient common.MongoClient
|
mongoClient common.MongoClient
|
||||||
sessionTTL time.Duration
|
sessionTTL time.Duration
|
||||||
serviceCodeBytes []byte
|
serviceCodeBytes []byte
|
||||||
@ -250,20 +250,13 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
sh.mongoClient = mg.mongoClient
|
sh.mongoClient = mg.mongoClient
|
||||||
sh.auths = mg.auths
|
sh.auths = mg.auths
|
||||||
sh.sessionTTL = time.Duration(mg.SessionTTL * int64(time.Second))
|
sh.sessionTTL = time.Duration(mg.SessionTTL * int64(time.Second))
|
||||||
sh.wl = whitelist{}
|
|
||||||
sh.serviceCodeBytes, _ = hex.DecodeString(sh.ServiceCode)
|
sh.serviceCodeBytes, _ = hex.DecodeString(sh.ServiceCode)
|
||||||
sh.getUserBrowserInfo = mg.GetUserBrowserInfo
|
sh.getUserBrowserInfo = mg.GetUserBrowserInfo
|
||||||
sh.getUserTokenWithCheck = mg.getUserTokenWithCheck
|
sh.getUserTokenWithCheck = mg.getUserTokenWithCheck
|
||||||
sh.updateUserinfo = mg.updateUserinfo
|
sh.updateUserinfo = mg.updateUserinfo
|
||||||
sh.getProviderInfo = mg.getProviderInfo
|
sh.getProviderInfo = mg.getProviderInfo
|
||||||
|
|
||||||
var whites []whitelistmember
|
|
||||||
if err := mg.mongoClient.AllAs(CollectionWhitelist, &whites, options.Find().SetReturnKey(false)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
sh.wl.init(whites)
|
|
||||||
sh.admins = unsafe.Pointer(&sh.Admins)
|
sh.admins = unsafe.Pointer(&sh.Admins)
|
||||||
|
sh.wl = &mg.wl
|
||||||
bt, _ := json.Marshal(sh)
|
bt, _ := json.Marshal(sh)
|
||||||
atomic.StorePointer(&sh.serviceSerialized, unsafe.Pointer(&bt))
|
atomic.StorePointer(&sh.serviceSerialized, unsafe.Pointer(&bt))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user