ServiceCode제거
This commit is contained in:
@ -286,9 +286,7 @@ func (caller apiCaller) serviceAPI(w http.ResponseWriter, r *http.Request) error
|
|||||||
if mg.service().Id.IsZero() {
|
if mg.service().Id.IsZero() {
|
||||||
logger.Println(" id is zero")
|
logger.Println(" id is zero")
|
||||||
newService := serviceDescription{
|
newService := serviceDescription{
|
||||||
ServiceDescriptionSummary: ServiceDescriptionSummary{
|
|
||||||
Id: primitive.NewObjectID(),
|
Id: primitive.NewObjectID(),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
if err := newService.prepare(caller.mg); err != nil {
|
if err := newService.prepare(caller.mg); err != nil {
|
||||||
logger.Println(" prepare failed :", err)
|
logger.Println(" prepare failed :", err)
|
||||||
|
|||||||
@ -411,9 +411,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
|||||||
atomic.StorePointer(&mg.serviceptr, unsafe.Pointer(only))
|
atomic.StorePointer(&mg.serviceptr, unsafe.Pointer(only))
|
||||||
} else {
|
} else {
|
||||||
empty := serviceDescription{
|
empty := serviceDescription{
|
||||||
ServiceDescriptionSummary: ServiceDescriptionSummary{
|
|
||||||
Id: primitive.NewObjectID(),
|
Id: primitive.NewObjectID(),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *devflag {
|
if *devflag {
|
||||||
@ -455,14 +453,13 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Println("Service is registered :", mg.service().ServiceCode)
|
|
||||||
if *devflag {
|
if *devflag {
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, mg.service().ServiceCode, "/"), func(w http.ResponseWriter, r *http.Request) {
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "/"), func(w http.ResponseWriter, r *http.Request) {
|
||||||
// mg.service()를 요청마다 불러야 함
|
// mg.service()를 요청마다 불러야 함
|
||||||
mg.service().serveHTTP_dev(w, r)
|
mg.service().serveHTTP_dev(w, r)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, mg.service().ServiceCode, "/"), func(w http.ResponseWriter, r *http.Request) {
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "/"), func(w http.ResponseWriter, r *http.Request) {
|
||||||
// mg.service()를 요청마다 불러야 함
|
// mg.service()를 요청마다 불러야 함
|
||||||
mg.service().serveHTTP(w, r)
|
mg.service().serveHTTP(w, r)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -93,13 +92,8 @@ type Division struct {
|
|||||||
Url string `bson:"url" json:"url"`
|
Url string `bson:"url" json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceDescriptionSummary struct {
|
|
||||||
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
|
||||||
ServiceCode string `bson:"code" json:"code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type serviceDescription struct {
|
type serviceDescription struct {
|
||||||
ServiceDescriptionSummary `bson:",inline" json:",inline"`
|
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
||||||
Divisions map[string]*Division `bson:"divisions" json:"divisions"`
|
Divisions map[string]*Division `bson:"divisions" json:"divisions"`
|
||||||
ServerApiTokens []primitive.ObjectID `bson:"api_tokens" json:"api_tokens"`
|
ServerApiTokens []primitive.ObjectID `bson:"api_tokens" json:"api_tokens"`
|
||||||
MaximumNumLinkAccount int64
|
MaximumNumLinkAccount int64
|
||||||
@ -111,7 +105,6 @@ type serviceDescription struct {
|
|||||||
mongoClient gocommon.MongoClient
|
mongoClient gocommon.MongoClient
|
||||||
sessionTTL time.Duration
|
sessionTTL time.Duration
|
||||||
|
|
||||||
serviceCodeBytes []byte
|
|
||||||
getUserBrowserInfo func(r *http.Request) (string, error)
|
getUserBrowserInfo func(r *http.Request) (string, error)
|
||||||
getUserTokenWithCheck func(platform string, userid string, brinfo string) (usertokeninfo, error)
|
getUserTokenWithCheck func(platform string, userid string, brinfo string) (usertokeninfo, error)
|
||||||
updateUserinfo func(info usertokeninfo) (bool, string, string)
|
updateUserinfo func(info usertokeninfo) (bool, string, string)
|
||||||
@ -173,13 +166,6 @@ func (sh *serviceDescription) readProfile(authtype string, id string, binfo stri
|
|||||||
|
|
||||||
func (sh *serviceDescription) prepare(mg *Maingate) error {
|
func (sh *serviceDescription) prepare(mg *Maingate) error {
|
||||||
divs := sh.Divisions
|
divs := sh.Divisions
|
||||||
if len(sh.ServiceCode) == 0 {
|
|
||||||
sh.ServiceCode = hex.EncodeToString(sh.Id[6:])
|
|
||||||
}
|
|
||||||
|
|
||||||
if *noauth {
|
|
||||||
sh.ServiceCode = "000000000000"
|
|
||||||
}
|
|
||||||
|
|
||||||
divsForUsers := make(map[string]*DivisionForUser)
|
divsForUsers := make(map[string]*DivisionForUser)
|
||||||
defaultDivNames := make(map[string]bool)
|
defaultDivNames := make(map[string]bool)
|
||||||
@ -250,7 +236,6 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
sh.mongoClient = mg.mongoClient
|
sh.mongoClient = mg.mongoClient
|
||||||
sh.sessionProvider = mg.sessionProvider
|
sh.sessionProvider = mg.sessionProvider
|
||||||
sh.sessionTTL = time.Duration(config.SessionTTL * int64(time.Second))
|
sh.sessionTTL = time.Duration(config.SessionTTL * int64(time.Second))
|
||||||
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
|
||||||
@ -276,8 +261,6 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
sh.bl = &mg.bl
|
sh.bl = &mg.bl
|
||||||
sh.serviceSerialized, _ = json.Marshal(sh)
|
sh.serviceSerialized, _ = json.Marshal(sh)
|
||||||
|
|
||||||
logger.Println("service is ready :", sh.ServiceCode, string(sh.serviceSerialized))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,9 +694,6 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
linkid := link["_id"].(primitive.ObjectID)
|
linkid := link["_id"].(primitive.ObjectID)
|
||||||
newaccid := primitive.NewObjectID()
|
newaccid := primitive.NewObjectID()
|
||||||
for i := 0; i < len(sh.serviceCodeBytes); i++ {
|
|
||||||
newaccid[i] ^= sh.serviceCodeBytes[i]
|
|
||||||
}
|
|
||||||
account, err := sh.mongoClient.FindOneAndUpdate(CollectionAccount, bson.M{
|
account, err := sh.mongoClient.FindOneAndUpdate(CollectionAccount, bson.M{
|
||||||
"_id": linkid,
|
"_id": linkid,
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
|
|||||||
Reference in New Issue
Block a user