파일 업로드 추가 / 화이트리스트에 권한 종류 추가
This commit is contained in:
@ -39,6 +39,7 @@ var (
|
||||
CollectionAuth = common.CollectionName("auth")
|
||||
CollectionWhitelist = common.CollectionName("whitelist")
|
||||
CollectionService = common.CollectionName("service")
|
||||
CollectionFile = common.CollectionName("file")
|
||||
CollectionBlock = common.CollectionName("block")
|
||||
CollectionPlatformLoginToken = common.CollectionName("platform_login_token") //-- 각 플랫폼에 로그인 및 권한 받아오는 과정에 사용하는 Key
|
||||
CollectionUserToken = common.CollectionName("usertoken")
|
||||
@ -434,6 +435,18 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = mg.mongoClient.MakeIndices(CollectionFile, map[string]bson.D{
|
||||
"service": {{Key: "service", Value: 1}},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionFile, map[string]bson.D{
|
||||
"sk": {{Key: "service", Value: 1}, {Key: "key", Value: 1}},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = mg.mongoClient.MakeExpireIndex(CollectionWhitelist, 10); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -482,6 +495,36 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
||||
|
||||
mg.auths = makeAuthCollection(mg.mongoClient, time.Duration(mg.SessionTTL*int64(time.Second)))
|
||||
|
||||
var preall []struct {
|
||||
Link string `bson:"link"`
|
||||
Id primitive.ObjectID `bson:"_id"`
|
||||
}
|
||||
if err = mg.mongoClient.FindAllAs(CollectionFile, nil, &preall, options.Find().SetProjection(bson.M{
|
||||
"link": 1,
|
||||
})); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, pre := range preall {
|
||||
_, err := os.Stat(pre.Link)
|
||||
if !os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
logger.Println("saving files :", pre.Link)
|
||||
|
||||
var fulldoc fileDocumentDesc
|
||||
err = mg.mongoClient.FindOneAs(CollectionFile, bson.M{
|
||||
"_id": pre.Id,
|
||||
}, &fulldoc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = fulldoc.save()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
go watchAuthCollection(context, mg.auths, mg.mongoClient)
|
||||
go mg.watchWhitelistCollection(context)
|
||||
|
||||
@ -579,7 +622,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
||||
serveMux.HandleFunc(common.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformFirebaseAuth), mg.platform_firebaseauth_authorize_sdk)
|
||||
|
||||
go mg.watchServiceCollection(ctx, serveMux, prefix)
|
||||
|
||||
go mg.watchFileCollection(ctx, serveMux, prefix)
|
||||
// fsx := http.FileServer(http.Dir("console"))
|
||||
// serveMux.Handle("/console/", http.StripPrefix("/console/", fsx))
|
||||
// logger.Println("console file server open")
|
||||
|
||||
Reference in New Issue
Block a user