Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d060fe117 | |||
| 231b1a35d5 | |||
| 845784d204 | |||
| 424c8be420 | |||
| ce39e8d878 | |||
| 54c727117b | |||
| 7816fd56c0 | |||
| 564a2ee14a | |||
| cbcae00c77 | |||
| 28dc84769d | |||
| 0c678947cd | |||
| dbd0a7bf5f | |||
| 86247e053d | |||
| 757c6d312c | |||
| e37a974d9c | |||
| 470591cb44 | |||
| 38114769b3 | |||
| b05473a1c6 | |||
| 0fff694e8a | |||
| d8713298c4 | |||
| 763b0fc4bd | |||
| d8e18d7ffc | |||
| 381f1edb80 | |||
| a8e448b8ca | |||
| 9b0e3a5d5b | |||
| 5757a81cb8 | |||
| c4b8e630dc | |||
| 43b0242652 | |||
| 893744a1ab | |||
| 192cc569b4 | |||
| 56e6608537 | |||
| 0053033e32 | |||
| d1ff6a56fc | |||
| 114461c51d | |||
| 117a3e5d90 | |||
| fafc463f2a | |||
| e2bec481f0 | |||
| 89e7d35b5a | |||
| fe662c5355 | |||
| 6767a37704 | |||
| 2ea035a43b | |||
| 2a1ad499ed | |||
| 5cc6ddc8f1 | |||
| 0e070221f8 | |||
| d2e06961b9 | |||
| 28092fcf17 | |||
| c43c10982c | |||
| 02c4f9e3d1 | |||
| 1db22730aa | |||
| 869fa48d74 | |||
| 7470f8e001 | |||
| fc70a9482c | |||
| 9ccd97564a | |||
| 4958cb0b93 | |||
| 9c14480be7 | |||
| daf3e3f027 | |||
| 2de82b9d2a | |||
| 00c2d6e205 | |||
| 87d922c558 | |||
| 0be7adefe3 | |||
| 3a9f81f1cb | |||
| a97b9f0983 | |||
| 9edea29983 | |||
| 8e908982a8 | |||
| 6b68d918ba | |||
| 3216e2620a | |||
| f66904d428 | |||
| 8d70777269 | |||
| 15ead6b0bc | |||
| 97636ce31d | |||
| 2b4becdb61 | |||
| 429bbd1e7a | |||
| 1c397da77a | |||
| 5502c4d744 | |||
| cb793092e9 | |||
| 13f6492e5f | |||
| f739eb3a8b | |||
| c95d7747cd | |||
| 841dad4992 | |||
| ff7d56152e | |||
| 2acca6dbe8 | |||
| 484db90037 | |||
| b06eb86578 | |||
| 9704decb7a | |||
| 767d6bf002 | |||
| 1f7421dd2e | |||
| 53701d61f8 | |||
| 6d02eb092c | |||
| 7bee78a875 |
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"maingate_mongodb_url": "mongodb://...",
|
"maingate_mongodb_url": "mongodb://...",
|
||||||
"session_storage": "",
|
|
||||||
"session_ttl" : 3600,
|
|
||||||
|
|
||||||
"autologin_ttl": 604800,
|
"autologin_ttl": 604800,
|
||||||
|
"acc_del_ttl": 7776000,
|
||||||
"maximum_num_link_account": 10,
|
"maximum_num_link_account": 10,
|
||||||
"redirect_base_url": "",
|
"redirect_base_url": "",
|
||||||
"google_client_id" : "",
|
"google_client_id" : "",
|
||||||
|
|||||||
238
core/api.go
238
core/api.go
@ -160,47 +160,39 @@ func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error
|
|||||||
|
|
||||||
func (caller apiCaller) blockAPI(w http.ResponseWriter, r *http.Request) error {
|
func (caller apiCaller) blockAPI(w http.ResponseWriter, r *http.Request) error {
|
||||||
mg := caller.mg
|
mg := caller.mg
|
||||||
logger.Println("blockAPI :", r.Method)
|
if r.Method == "GET" {
|
||||||
switch r.Method {
|
json.NewEncoder(w).Encode(mg.bl.all())
|
||||||
case "GET":
|
} else if r.Method == "PUT" {
|
||||||
target, ok := gocommon.ReadObjectIDFormValue(r.Form, "accid")
|
body, _ := io.ReadAll(r.Body)
|
||||||
if !ok {
|
|
||||||
// 페이지네이션 해야할 듯
|
var bipl blockinfoWithStringId
|
||||||
//json.NewEncoder(w).Encode(mg.bl.all())
|
if err := json.Unmarshal(body, &bipl); err != nil {
|
||||||
} else if !target.IsZero() {
|
|
||||||
var blocked []blockinfo
|
|
||||||
if err := caller.mg.mongoClient.FindAllAs(CollectionBlock, bson.M{
|
|
||||||
"accid": target,
|
|
||||||
}, &blocked); err == nil {
|
|
||||||
json.NewEncoder(w).Encode(blocked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "PUT":
|
|
||||||
var targets struct {
|
|
||||||
Start primitive.DateTime
|
|
||||||
End primitive.DateTime
|
|
||||||
Accounts map[primitive.ObjectID]primitive.M // accid->meta
|
|
||||||
}
|
|
||||||
if err := gocommon.MakeDecoder(r).Decode(&targets); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for accid, meta := range targets.Accounts {
|
accid, err := primitive.ObjectIDFromHex(bipl.StrId)
|
||||||
bi := blockinfo{
|
if err != nil {
|
||||||
Start: targets.Start,
|
return err
|
||||||
End: targets.End,
|
|
||||||
Meta: meta,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := mg.mongoClient.Collection(CollectionBlock).InsertOne(r.Context(), bi)
|
bi := blockinfo{
|
||||||
|
Start: primitive.NewDateTimeFromTime(time.Unix(bipl.StartUnix, 0)),
|
||||||
|
End: primitive.NewDateTimeFromTime(time.Unix(bipl.EndUnix, 0)),
|
||||||
|
Reason: bipl.Reason,
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Println("bi :", accid, bi)
|
||||||
|
|
||||||
|
_, _, err = mg.mongoClient.Update(CollectionBlock, bson.M{
|
||||||
|
"_id": accid,
|
||||||
|
}, bson.M{
|
||||||
|
"$set": &bi,
|
||||||
|
}, options.Update().SetUpsert(true))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Println("account is not blocked. err :", err)
|
return err
|
||||||
} else {
|
|
||||||
logger.Println("account is blocked :", meta)
|
|
||||||
mg.sessionProvider.RevokeAll(accid)
|
|
||||||
}
|
}
|
||||||
}
|
} else if r.Method == "DELETE" {
|
||||||
case "DELETE":
|
|
||||||
id := r.URL.Query().Get("id")
|
id := r.URL.Query().Get("id")
|
||||||
|
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
@ -211,30 +203,38 @@ func (caller apiCaller) blockAPI(w http.ResponseWriter, r *http.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mg.mongoClient.Delete(CollectionBlock, bson.M{"_id": idobj})
|
_, _, err = mg.mongoClient.Update(CollectionBlock, bson.M{
|
||||||
|
"_id": idobj,
|
||||||
|
}, bson.M{
|
||||||
|
"$currentDate": bson.M{
|
||||||
|
"_ts": bson.M{"$type": "date"},
|
||||||
|
},
|
||||||
|
}, options.Update().SetUpsert(false))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mg.mongoClient.Delete(CollectionAuth, bson.M{"_id": idobj})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (caller apiCaller) whitelistAPI(w http.ResponseWriter, r *http.Request) error {
|
func (caller apiCaller) whitelistAPI(w http.ResponseWriter, r *http.Request) error {
|
||||||
mg := caller.mg
|
mg := caller.mg
|
||||||
switch r.Method {
|
if r.Method == "GET" {
|
||||||
case "GET":
|
|
||||||
var all []whitelistmember
|
|
||||||
if err := mg.mongoClient.AllAs(CollectionWhitelist, &all); err == nil {
|
|
||||||
enc := json.NewEncoder(w)
|
enc := json.NewEncoder(w)
|
||||||
enc.Encode(all)
|
enc.Encode(mg.wl.all())
|
||||||
}
|
} else if r.Method == "PUT" {
|
||||||
case "PUT":
|
|
||||||
body, _ := io.ReadAll(r.Body)
|
body, _ := io.ReadAll(r.Body)
|
||||||
var member whitelistmember
|
var member whitelistmember
|
||||||
if err := json.Unmarshal(body, &member); err != nil {
|
if err := json.Unmarshal(body, &member); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
member.ExpiredAt = 0
|
member.ExpiredAt = 0
|
||||||
member.Id = primitive.NewObjectID()
|
member.Id = primitive.NilObjectID
|
||||||
_, _, err := mg.mongoClient.Update(CollectionWhitelist, bson.M{
|
_, _, err := mg.mongoClient.Update(CollectionWhitelist, bson.M{
|
||||||
"_id": member.Id,
|
"_id": primitive.NewObjectID(),
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$set": &member,
|
"$set": &member,
|
||||||
}, options.Update().SetUpsert(true))
|
}, options.Update().SetUpsert(true))
|
||||||
@ -242,7 +242,7 @@ func (caller apiCaller) whitelistAPI(w http.ResponseWriter, r *http.Request) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "DELETE":
|
} else if r.Method == "DELETE" {
|
||||||
id := r.URL.Query().Get("id")
|
id := r.URL.Query().Get("id")
|
||||||
|
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
@ -274,7 +274,9 @@ 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)
|
||||||
@ -370,78 +372,12 @@ func (caller apiCaller) couponAPI(w http.ResponseWriter, r *http.Request) error
|
|||||||
logger.Println("begin listAllCouponNames")
|
logger.Println("begin listAllCouponNames")
|
||||||
listAllCouponNames(caller.mg.mongoClient, w, r)
|
listAllCouponNames(caller.mg.mongoClient, w, r)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type accountlinkinfo struct {
|
case "DELETE":
|
||||||
Uid string `json:"uid"`
|
// 쿠폰 삭제
|
||||||
Platform string `json:"platform"`
|
logger.Println("begin deleteCoupon")
|
||||||
|
deleteCoupon(caller.mg.mongoClient, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (caller apiCaller) userinfoAPI(w http.ResponseWriter, r *http.Request) error {
|
|
||||||
mg := caller.mg
|
|
||||||
if r.Method == "GET" {
|
|
||||||
// 계정 조회
|
|
||||||
accid, _ := gocommon.ReadObjectIDFormValue(r.Form, "accid")
|
|
||||||
if len(accid) > 0 {
|
|
||||||
all, err := mg.mongoClient.FindAll(CollectionAccount, bson.M{
|
|
||||||
"accid": accid,
|
|
||||||
}, options.Find().SetProjection(bson.M{"_id": 1, "accid": 1}))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var linkinfos []accountlinkinfo
|
|
||||||
for _, doc := range all {
|
|
||||||
id := doc["_id"].(primitive.ObjectID)
|
|
||||||
|
|
||||||
link, err := mg.mongoClient.FindOne(CollectionLink, bson.M{
|
|
||||||
"_id": id,
|
|
||||||
}, options.FindOne().SetProjection(bson.M{"_id": 1, "platform": 1, "uid": 1}))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
logger.Error("link failed. FindOneAndUpdate link err:", err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var info accountlinkinfo
|
|
||||||
info.Platform = link["platform"].(string)
|
|
||||||
info.Uid = link["uid"].(string)
|
|
||||||
linkinfos = append(linkinfos, info)
|
|
||||||
}
|
|
||||||
|
|
||||||
enc := json.NewEncoder(w)
|
|
||||||
enc.Encode(linkinfos)
|
|
||||||
}
|
|
||||||
} else if r.Method == "POST" {
|
|
||||||
r.ParseMultipartForm(32 << 20)
|
|
||||||
var body struct {
|
|
||||||
Platform string
|
|
||||||
Uid []string
|
|
||||||
}
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(body.Platform) > 0 && len(body.Uid) > 0 {
|
|
||||||
output := make(map[string]any)
|
|
||||||
for _, uid := range body.Uid {
|
|
||||||
link, err := mg.mongoClient.FindOne(CollectionLink, bson.M{
|
|
||||||
"platform": body.Platform,
|
|
||||||
"uid": uid,
|
|
||||||
}, options.FindOne().SetProjection(bson.M{"_id": 1}))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
output[uid] = link["_id"]
|
|
||||||
}
|
|
||||||
json.NewEncoder(w).Encode(output)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +401,40 @@ func (caller apiCaller) configAPI(w http.ResponseWriter, r *http.Request) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (caller apiCaller) lockcreatecharAPI(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
mg, err := caller.mg.mongoClient.FindAll(CollectionService, bson.M{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
haschr, _ := gocommon.ReadStringFormValue(r.Form, "haschr")
|
||||||
|
|
||||||
|
locked := make(map[string]any)
|
||||||
|
if haschr == "true" {
|
||||||
|
locked["lock"] = false
|
||||||
|
} else {
|
||||||
|
curregion, _ := gocommon.ReadStringFormValue(r.Form, "region")
|
||||||
|
|
||||||
|
for _, regioninfo := range mg {
|
||||||
|
region := regioninfo["divisions"].(primitive.M)
|
||||||
|
for idx, rl := range region {
|
||||||
|
if idx == curregion {
|
||||||
|
if rl.(primitive.M)["lockcreatechar"].(bool) {
|
||||||
|
locked["lock"] = true
|
||||||
|
} else {
|
||||||
|
locked["lock"] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
create, _ := json.Marshal(locked)
|
||||||
|
w.Write(create)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type apiCaller struct {
|
type apiCaller struct {
|
||||||
userinfo map[string]any
|
userinfo map[string]any
|
||||||
globalAdmins map[string]bool
|
globalAdmins map[string]bool
|
||||||
@ -489,11 +459,28 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var userinfo map[string]any
|
var userinfo map[string]any
|
||||||
|
|
||||||
|
var apiTokenObj primitive.ObjectID
|
||||||
if !*devflag {
|
if !*devflag {
|
||||||
|
apiToken := r.Header.Get("MG-X-API-TOKEN")
|
||||||
|
if len(apiToken) > 0 {
|
||||||
|
if apiToken != mg.maingateConfig.ApiToken {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
obj, err := primitive.ObjectIDFromHex(apiToken)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
apiTokenObj = obj
|
||||||
|
} else {
|
||||||
authheader := r.Header.Get("Authorization")
|
authheader := r.Header.Get("Authorization")
|
||||||
if len(authheader) == 0 {
|
if len(authheader) == 0 {
|
||||||
logger.Println("Authorization header is not valid :", authheader)
|
logger.Println("Authorization header is not valid :", authheader)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,6 +506,7 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ptr := atomic.LoadPointer(&mg.admins)
|
ptr := atomic.LoadPointer(&mg.admins)
|
||||||
adminsptr := (*globalAdmins)(ptr)
|
adminsptr := (*globalAdmins)(ptr)
|
||||||
@ -532,20 +520,6 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiTokenObj primitive.ObjectID
|
|
||||||
if !*devflag {
|
|
||||||
apiToken := r.Header.Get("MG-X-API-TOKEN")
|
|
||||||
if len(apiToken) > 0 {
|
|
||||||
obj, err := primitive.ObjectIDFromHex(apiToken)
|
|
||||||
if err != nil {
|
|
||||||
logger.Error(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
apiTokenObj = obj
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Println("api call :", r.URL.Path, r.Method, r.URL.Query(), userinfo)
|
logger.Println("api call :", r.URL.Path, r.Method, r.URL.Query(), userinfo)
|
||||||
caller := apiCaller{
|
caller := apiCaller{
|
||||||
userinfo: userinfo,
|
userinfo: userinfo,
|
||||||
@ -571,8 +545,8 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) {
|
|||||||
err = caller.blockAPI(w, r)
|
err = caller.blockAPI(w, r)
|
||||||
} else if strings.HasSuffix(r.URL.Path, "/coupon") {
|
} else if strings.HasSuffix(r.URL.Path, "/coupon") {
|
||||||
err = caller.couponAPI(w, r)
|
err = caller.couponAPI(w, r)
|
||||||
} else if strings.HasSuffix(r.URL.Path, "/userinfo") {
|
} else if strings.HasSuffix(r.URL.Path, "/lockcreatechar") {
|
||||||
err = caller.userinfoAPI(w, r)
|
err = caller.lockcreatecharAPI(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -30,6 +30,7 @@ type couponDoc struct {
|
|||||||
Total int64 `json:"total" bson:"total"`
|
Total int64 `json:"total" bson:"total"`
|
||||||
Remains []string `json:"remains,omitempty" bson:"remains,omitempty"`
|
Remains []string `json:"remains,omitempty" bson:"remains,omitempty"`
|
||||||
Used []string `json:"used,omitempty" bson:"used,omitempty"`
|
Used []string `json:"used,omitempty" bson:"used,omitempty"`
|
||||||
|
Expire int64 `json:"expire" bson:"expire"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeCouponKey(roundnum uint32, uid []byte) string {
|
func makeCouponKey(roundnum uint32, uid []byte) string {
|
||||||
@ -44,17 +45,17 @@ func makeCouponKey(roundnum uint32, uid []byte) string {
|
|||||||
return fmt.Sprintf("%s-%s-%s-%s", hex.EncodeToString(final[0:2]), hex.EncodeToString(final[2:4]), hex.EncodeToString(final[4:6]), hex.EncodeToString(final[6:8]))
|
return fmt.Sprintf("%s-%s-%s-%s", hex.EncodeToString(final[0:2]), hex.EncodeToString(final[2:4]), hex.EncodeToString(final[4:6]), hex.EncodeToString(final[6:8]))
|
||||||
}
|
}
|
||||||
|
|
||||||
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
||||||
|
|
||||||
func makeCouponCodes(name string, count int) (string, map[string]string) {
|
func makeCouponCodes(name string, count int) (string, map[string]string) {
|
||||||
checkunique := make(map[string]bool)
|
checkunique := make(map[string]bool)
|
||||||
keys := make(map[string]string)
|
keys := make(map[string]string)
|
||||||
uid := make([]byte, 4)
|
uid := make([]byte, 4)
|
||||||
|
|
||||||
roundHash, roundnum := coupon.MakeCouponRoundHash(name)
|
roundHash, roundnum := coupon.MakeCouponRoundHash(name)
|
||||||
|
seed := time.Now().UnixNano()
|
||||||
|
|
||||||
for len(keys) < count {
|
for len(keys) < count {
|
||||||
r.Read(uid)
|
rand.Seed(seed)
|
||||||
|
rand.Read(uid)
|
||||||
|
|
||||||
code := makeCouponKey(roundnum, uid)
|
code := makeCouponKey(roundnum, uid)
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ func makeCouponCodes(name string, count int) (string, map[string]string) {
|
|||||||
checkunique[code] = true
|
checkunique[code] = true
|
||||||
keys[hex.EncodeToString(uid)] = code
|
keys[hex.EncodeToString(uid)] = code
|
||||||
}
|
}
|
||||||
|
seed = int64(binary.BigEndian.Uint32(uid))
|
||||||
}
|
}
|
||||||
return roundHash, keys
|
return roundHash, keys
|
||||||
}
|
}
|
||||||
@ -71,6 +73,7 @@ func generateCoupons(mongoClient gocommon.MongoClient, w http.ResponseWriter, r
|
|||||||
effect, _ := gocommon.ReadStringFormValue(r.Form, "effect")
|
effect, _ := gocommon.ReadStringFormValue(r.Form, "effect")
|
||||||
count, _ := gocommon.ReadIntegerFormValue(r.Form, "count")
|
count, _ := gocommon.ReadIntegerFormValue(r.Form, "count")
|
||||||
desc, _ := gocommon.ReadStringFormValue(r.Form, "desc")
|
desc, _ := gocommon.ReadStringFormValue(r.Form, "desc")
|
||||||
|
expire, _ := gocommon.ReadIntegerFormValue(r.Form, "expire")
|
||||||
|
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
logger.Println("[generateCoupons] count == 0")
|
logger.Println("[generateCoupons] count == 0")
|
||||||
@ -91,6 +94,7 @@ func generateCoupons(mongoClient gocommon.MongoClient, w http.ResponseWriter, r
|
|||||||
Effect: effect,
|
Effect: effect,
|
||||||
Desc: desc,
|
Desc: desc,
|
||||||
Total: -1,
|
Total: -1,
|
||||||
|
Expire: expire,
|
||||||
},
|
},
|
||||||
}, options.Update().SetUpsert(true)); err != nil {
|
}, options.Update().SetUpsert(true)); err != nil {
|
||||||
logger.Println("[generateCoupons] Update failed :", err)
|
logger.Println("[generateCoupons] Update failed :", err)
|
||||||
@ -153,6 +157,7 @@ func generateCoupons(mongoClient gocommon.MongoClient, w http.ResponseWriter, r
|
|||||||
Effect: effect,
|
Effect: effect,
|
||||||
Desc: desc,
|
Desc: desc,
|
||||||
Total: count,
|
Total: count,
|
||||||
|
Expire: expire,
|
||||||
},
|
},
|
||||||
}, options.Update().SetUpsert(true))
|
}, options.Update().SetUpsert(true))
|
||||||
}
|
}
|
||||||
@ -235,7 +240,7 @@ func queryCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *htt
|
|||||||
var coupon couponDoc
|
var coupon couponDoc
|
||||||
if err := mongoClient.FindOneAs(CollectionCoupon, bson.M{
|
if err := mongoClient.FindOneAs(CollectionCoupon, bson.M{
|
||||||
"_id": roundObj,
|
"_id": roundObj,
|
||||||
}, &coupon, options.FindOne().SetProjection(bson.M{"effect": 1, "name": 1, "reason": 1, "total": 1, "desc": 1}).SetReturnKey(false)); err != nil {
|
}, &coupon, options.FindOne().SetProjection(bson.M{"effect": 1, "name": 1, "reason": 1, "total": 1, "desc": 1, "expire": 1}).SetReturnKey(false)); err != nil {
|
||||||
logger.Println("[queryCoupon] FindOneAs failed :", err)
|
logger.Println("[queryCoupon] FindOneAs failed :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -302,7 +307,7 @@ func useCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *http.
|
|||||||
// 무한 쿠폰일 수 있으므로 존재하는지 확인
|
// 무한 쿠폰일 수 있으므로 존재하는지 확인
|
||||||
if err := mongoClient.FindOneAs(CollectionCoupon, bson.M{
|
if err := mongoClient.FindOneAs(CollectionCoupon, bson.M{
|
||||||
"_id": roundObj,
|
"_id": roundObj,
|
||||||
}, &coupon, options.FindOne().SetProjection(bson.M{"_id": 0, "effect": 1, "name": 1, "reason": 1, "total": 1})); err != nil {
|
}, &coupon, options.FindOne().SetProjection(bson.M{"_id": 0, "effect": 1, "name": 1, "total": 1, "expire": 1})); err != nil {
|
||||||
logger.Println(err)
|
logger.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -314,7 +319,7 @@ func useCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *http.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 2. 쿠폰을 하나 꺼냄
|
// 쿠폰을 하나 꺼냄
|
||||||
matched, _, err := mongoClient.Update(CollectionCoupon, bson.M{
|
matched, _, err := mongoClient.Update(CollectionCoupon, bson.M{
|
||||||
"_id": roundObj,
|
"_id": roundObj,
|
||||||
"remains": key,
|
"remains": key,
|
||||||
@ -333,18 +338,24 @@ func useCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *http.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. round의 효과 읽기
|
// round의 효과 읽기
|
||||||
if err := mongoClient.FindOneAndUpdateAs(CollectionCoupon, bson.M{
|
if err := mongoClient.FindOneAndUpdateAs(CollectionCoupon, bson.M{
|
||||||
"_id": roundObj,
|
"_id": roundObj,
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$push": bson.M{"used": key},
|
"$push": bson.M{"used": key},
|
||||||
}, &coupon, options.FindOneAndUpdate().SetProjection(bson.M{"effect": 1})); err != nil {
|
}, &coupon, options.FindOneAndUpdate().SetProjection(bson.M{"effect": 1, "expire": 1})); err != nil {
|
||||||
logger.Println(err)
|
logger.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if coupon.Expire < time.Now().Unix() {
|
||||||
|
// 쿠폰 만료시간 경과
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(coupon.Effect) == 0 {
|
if len(coupon.Effect) == 0 {
|
||||||
// 쿠폰이 없네?
|
// 쿠폰이 없네?
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -375,3 +386,22 @@ func useCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *http.
|
|||||||
|
|
||||||
w.Write([]byte(coupon.Effect))
|
w.Write([]byte(coupon.Effect))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteCoupon(mongoClient gocommon.MongoClient, w http.ResponseWriter, r *http.Request) {
|
||||||
|
code, _ := gocommon.ReadStringFormValue(r.Form, "name")
|
||||||
|
if len(code) == 0 {
|
||||||
|
logger.Println("coupon delete code error")
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := mongoClient.Delete(CollectionCoupon, bson.M{
|
||||||
|
"name": code,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.Println("coupon delete error")
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,9 +1,39 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMakeLocalUniqueId(t *testing.T) {
|
func TestMakeLocalUniqueId(t *testing.T) {
|
||||||
|
ts := int64(1690815600)
|
||||||
|
start := primitive.NewDateTimeFromTime(time.Unix(ts, 0))
|
||||||
|
ts = int64(1693493999)
|
||||||
|
end := primitive.NewDateTimeFromTime(time.Unix(ts, 0))
|
||||||
|
|
||||||
|
fmt.Println(start.Time().Format(time.RFC3339))
|
||||||
|
fmt.Println(end.Time().Format(time.RFC3339))
|
||||||
|
|
||||||
|
mongoClient, err := gocommon.NewMongoClient(context.Background(), "mongodb://121.134.91.160:27018/mountain-maingate?replicaSet=rs0&retrywrites=true", "maingate")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bi := blockinfo{
|
||||||
|
Start: start,
|
||||||
|
End: end,
|
||||||
|
Reason: "test",
|
||||||
|
}
|
||||||
|
mongoClient.Update(CollectionBlock, bson.M{
|
||||||
|
"_id": primitive.NewObjectID(),
|
||||||
|
}, bson.M{
|
||||||
|
"$set": &bi,
|
||||||
|
}, options.Update().SetUpsert(true))
|
||||||
}
|
}
|
||||||
|
|||||||
342
core/maingate.go
342
core/maingate.go
@ -9,9 +9,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"text/template"
|
"text/template"
|
||||||
@ -21,7 +23,6 @@ import (
|
|||||||
"repositories.action2quare.com/ayo/gocommon"
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
"repositories.action2quare.com/ayo/gocommon/session"
|
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt"
|
"github.com/golang-jwt/jwt"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@ -36,10 +37,10 @@ import (
|
|||||||
|
|
||||||
var devflag = flagx.Bool("dev", false, "")
|
var devflag = flagx.Bool("dev", false, "")
|
||||||
var noauth = flagx.Bool("noauth", false, "")
|
var noauth = flagx.Bool("noauth", false, "")
|
||||||
var authtype = flagx.String("auth", "on", "on|off|both")
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CollectionLink = gocommon.CollectionName("link")
|
CollectionLink = gocommon.CollectionName("link")
|
||||||
|
CollectionAuth = gocommon.CollectionName("auth")
|
||||||
CollectionWhitelist = gocommon.CollectionName("whitelist")
|
CollectionWhitelist = gocommon.CollectionName("whitelist")
|
||||||
CollectionService = gocommon.CollectionName("service")
|
CollectionService = gocommon.CollectionName("service")
|
||||||
CollectionAccount = gocommon.CollectionName("account")
|
CollectionAccount = gocommon.CollectionName("account")
|
||||||
@ -58,7 +59,6 @@ const (
|
|||||||
AuthPlatformMicrosoft = "microsoft"
|
AuthPlatformMicrosoft = "microsoft"
|
||||||
AuthPlatformApple = "apple"
|
AuthPlatformApple = "apple"
|
||||||
AuthPlatformTwitter = "twitter"
|
AuthPlatformTwitter = "twitter"
|
||||||
AuthPlatformHybeim = "hybeim"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -74,10 +74,56 @@ func SessionTTL() time.Duration {
|
|||||||
return sessionTTL
|
return sessionTTL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mongoAuthCell struct {
|
||||||
|
src *gocommon.Authinfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac *mongoAuthCell) ToAuthinfo() *gocommon.Authinfo {
|
||||||
|
if ac.src == nil {
|
||||||
|
logger.Error("mongoAuthCell ToAuthinfo failed. ac.src is nil")
|
||||||
|
}
|
||||||
|
return ac.src
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac *mongoAuthCell) ToBytes() []byte {
|
||||||
|
bt, _ := json.Marshal(ac.src)
|
||||||
|
return bt
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeAuthCollection(mongoClient gocommon.MongoClient, sessionTTL time.Duration) *gocommon.AuthCollection {
|
||||||
|
authcoll := gocommon.MakeAuthCollection(sessionTTL)
|
||||||
|
authcoll.SessionRemoved = func(sk string) {
|
||||||
|
skid, _ := primitive.ObjectIDFromHex(sk)
|
||||||
|
mongoClient.Delete(CollectionAuth, bson.M{
|
||||||
|
"sk": skid,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
authcoll.QuerySession = func(sk string, token string) gocommon.AuthinfoCell {
|
||||||
|
skid, _ := primitive.ObjectIDFromHex(sk)
|
||||||
|
var outcell mongoAuthCell
|
||||||
|
err := mongoClient.FindOneAs(CollectionAuth, bson.M{
|
||||||
|
"sk": skid,
|
||||||
|
}, &outcell.src, options.FindOne().SetHint("skonly"))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("QuerySession failed :", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if outcell.src == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &outcell
|
||||||
|
}
|
||||||
|
|
||||||
|
return authcoll
|
||||||
|
}
|
||||||
|
|
||||||
type maingateConfig struct {
|
type maingateConfig struct {
|
||||||
session.SessionConfig `json:",inline"`
|
|
||||||
MustUseChecksum bool `json:"maingate_must_checksum"`
|
|
||||||
Mongo string `json:"maingate_mongodb_url"`
|
Mongo string `json:"maingate_mongodb_url"`
|
||||||
|
SessionTTL int64 `json:"maingate_session_ttl"`
|
||||||
|
ApiToken string `json:"maingate_api_token"`
|
||||||
Autologin_ttl int64 `json:"autologin_ttl"`
|
Autologin_ttl int64 `json:"autologin_ttl"`
|
||||||
AccDelTTL int64 `json:"acc_del_ttl"`
|
AccDelTTL int64 `json:"acc_del_ttl"`
|
||||||
MaximumNumLinkAccount int64 `json:"maximum_num_link_account"`
|
MaximumNumLinkAccount int64 `json:"maximum_num_link_account"`
|
||||||
@ -100,12 +146,6 @@ type maingateConfig struct {
|
|||||||
FirebaseAdminSDKCredentialFile string `json:"firebase_admin_sdk_credentialfile"`
|
FirebaseAdminSDKCredentialFile string `json:"firebase_admin_sdk_credentialfile"`
|
||||||
SteamAppId string `json:"steam_app_id"`
|
SteamAppId string `json:"steam_app_id"`
|
||||||
SteamPublisherAuthKey string `json:"steam_publisher_authkey"`
|
SteamPublisherAuthKey string `json:"steam_publisher_authkey"`
|
||||||
GlobalMaingateToken string `json:"maingate_api_token"`
|
|
||||||
HybeImProjectIdstring string `json:"hybeim_projectid"`
|
|
||||||
HybeImServiceIdstring string `json:"hybeim_serviceid"`
|
|
||||||
HybeImAccessKey string `json:"hybeim_acesskey"`
|
|
||||||
HybeImEndPoint string `json:"hybeim_Endpoint"`
|
|
||||||
|
|
||||||
Firebase_Google_Analytics_JS_SDK_Config
|
Firebase_Google_Analytics_JS_SDK_Config
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,32 +175,30 @@ func (ga *globalAdmins) parse() {
|
|||||||
ga.modtime = gocommon.ConfigModTime()
|
ga.modtime = gocommon.ConfigModTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
type firebaseClient struct {
|
|
||||||
firebaseAppClient *auth.Client
|
|
||||||
firebaseAppContext context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maingate :
|
// Maingate :
|
||||||
type Maingate struct {
|
type Maingate struct {
|
||||||
|
maingateConfig
|
||||||
|
|
||||||
mongoClient gocommon.MongoClient
|
mongoClient gocommon.MongoClient
|
||||||
|
|
||||||
sessionProvider session.Provider
|
auths *gocommon.AuthCollection
|
||||||
//services servicelist
|
//services servicelist
|
||||||
serviceptr unsafe.Pointer
|
serviceptr unsafe.Pointer
|
||||||
admins unsafe.Pointer
|
admins unsafe.Pointer
|
||||||
|
wl memberContainerPtr[string, *whitelistmember]
|
||||||
|
bl memberContainerPtr[primitive.ObjectID, *blockinfo]
|
||||||
|
|
||||||
tokenEndpoints map[string]string
|
tokenEndpoints map[string]string
|
||||||
authorizationEndpoints map[string]string
|
authorizationEndpoints map[string]string
|
||||||
userinfoEndpoint map[string]string
|
userinfoEndpoint map[string]string
|
||||||
jwksUri map[string]string
|
jwksUri map[string]string
|
||||||
|
firebaseAppClient *auth.Client
|
||||||
firebase *firebaseClient
|
firebaseAppContext context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
var config maingateConfig
|
|
||||||
|
|
||||||
// New :
|
// New :
|
||||||
func New(ctx context.Context) (*Maingate, error) {
|
func New(ctx context.Context) (*Maingate, error) {
|
||||||
|
var config maingateConfig
|
||||||
if err := gocommon.LoadConfig(&config); err != nil {
|
if err := gocommon.LoadConfig(&config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -170,15 +208,12 @@ func New(ctx context.Context) (*Maingate, error) {
|
|||||||
admins.parse()
|
admins.parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.SessionStorage) == 0 {
|
|
||||||
return nil, errors.New("maingate_session_storage is missing")
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.SessionTTL == 0 {
|
if config.SessionTTL == 0 {
|
||||||
config.SessionTTL = 3600
|
config.SessionTTL = 3600
|
||||||
}
|
}
|
||||||
|
|
||||||
mg := Maingate{
|
mg := Maingate{
|
||||||
|
maingateConfig: config,
|
||||||
admins: unsafe.Pointer(&admins),
|
admins: unsafe.Pointer(&admins),
|
||||||
tokenEndpoints: make(map[string]string),
|
tokenEndpoints: make(map[string]string),
|
||||||
authorizationEndpoints: make(map[string]string),
|
authorizationEndpoints: make(map[string]string),
|
||||||
@ -191,29 +226,18 @@ func New(ctx context.Context) (*Maingate, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(*authtype) == 0 {
|
if !*noauth {
|
||||||
*authtype = "on"
|
opt := option.WithCredentialsFile(mg.FirebaseAdminSDKCredentialFile)
|
||||||
}
|
|
||||||
|
|
||||||
if !*noauth && (*authtype == "on" || *authtype == "both") {
|
|
||||||
if len(config.FirebaseAdminSDKCredentialFile) > 0 {
|
|
||||||
opt := option.WithCredentialsFile(config.FirebaseAdminSDKCredentialFile)
|
|
||||||
firebaseApp, err := firebase.NewApp(context.Background(), nil, opt)
|
firebaseApp, err := firebase.NewApp(context.Background(), nil, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("firebase admin error initializing app failed :", err)
|
logger.Error("firebase admin error initializing app failed :", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
firebaseAppClient, err := firebaseApp.Auth(ctx)
|
mg.firebaseAppContext = ctx
|
||||||
|
mg.firebaseAppClient, err = firebaseApp.Auth(mg.firebaseAppContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Println("FirebaseAppClient error getting Auth client:", err)
|
logger.Println("FirebaseAppClient error getting Auth client:", err)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mg.firebase = &firebaseClient{
|
|
||||||
firebaseAppContext: ctx,
|
|
||||||
firebaseAppClient: firebaseAppClient,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,115 +302,110 @@ func (mg *Maingate) discoverOpenIdConfiguration(name string, url string) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeErrorWithStack(err error) error {
|
||||||
|
return fmt.Errorf("%s\n%s", err.Error(), string(debug.Stack()))
|
||||||
|
}
|
||||||
|
|
||||||
func (mg *Maingate) prepare(context context.Context) (err error) {
|
func (mg *Maingate) prepare(context context.Context) (err error) {
|
||||||
if err := mg.discoverOpenIdConfiguration(AuthPlatformMicrosoft, "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration"); err != nil {
|
if err := mg.discoverOpenIdConfiguration(AuthPlatformMicrosoft, "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration"); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
if err := mg.discoverOpenIdConfiguration("google", "https://accounts.google.com/.well-known/openid-configuration"); err != nil {
|
if err := mg.discoverOpenIdConfiguration("google", "https://accounts.google.com/.well-known/openid-configuration"); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// redis에서 env를 가져온 후에
|
// redis에서 env를 가져온 후에
|
||||||
mg.mongoClient, err = gocommon.NewMongoClient(context, config.Mongo)
|
mg.mongoClient, err = gocommon.NewMongoClient(context, mg.Mongo, "maingate")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionCouponUse, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionCouponUse, map[string]bson.D{
|
||||||
"idrounds": {{Key: "_id", Value: 1}, {Key: "rounds", Value: 1}},
|
"idrounds": {{Key: "_id", Value: 1}, {Key: "rounds", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionAuth, map[string]bson.D{
|
||||||
|
"skonly": {{Key: "sk", Value: 1}},
|
||||||
|
}); err != nil {
|
||||||
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionLink, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionLink, map[string]bson.D{
|
||||||
"platformuid": {{Key: "platform", Value: 1}, {Key: "uid", Value: 1}},
|
"platformuid": {{Key: "platform", Value: 1}, {Key: "uid", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if err = mg.mongoClient.MakeUniqueIndices(CollectionLink, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionLink, map[string]bson.D{
|
||||||
// "emailplatform": {{Key: "email", Value: 1}, {Key: "platform", Value: 1}},
|
"emailplatform": {{Key: "email", Value: 1}, {Key: "platform", Value: 1}},
|
||||||
// }); err != nil {
|
}); err != nil {
|
||||||
// return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
// }
|
|
||||||
if err = mg.mongoClient.DropIndex(CollectionLink, "emailplatform"); err != nil {
|
|
||||||
return logger.ErrorWithCallStack(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeIndices(CollectionAccount, map[string]bson.D{
|
if err = mg.mongoClient.MakeIndices(CollectionAccount, map[string]bson.D{
|
||||||
"accid": {{Key: "accid", Value: 1}},
|
"accid": {{Key: "accid", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionFile, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionFile, map[string]bson.D{
|
||||||
"keyonly": {{Key: "key", Value: 1}},
|
"keyonly": {{Key: "key", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeExpireIndex(CollectionAccount, int32(config.AccDelTTL)); err != nil {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionAccount, int32(mg.AccDelTTL)); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeExpireIndex(CollectionLink, int32(config.AccDelTTL)); err != nil {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionLink, int32(mg.AccDelTTL)); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete대신 _ts로 expire시킴. pipeline에 삭제 알려주기 위함
|
// Delete대신 _ts로 expire시킴. pipeline에 삭제 알려주기 위함
|
||||||
if err = mg.mongoClient.MakeExpireIndex(CollectionWhitelist, 10); err != nil {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionWhitelist, 10); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *devflag {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionAuth, int32(mg.SessionTTL+300)); err != nil {
|
||||||
// 에러 체크하지 말것
|
return makeErrorWithStack(err)
|
||||||
mg.mongoClient.DropIndex(CollectionBlock, "codeaccid")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := mg.mongoClient.Collection(CollectionBlock).Indexes().DropOne(context, "_ts_1"); err == nil {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionBlock, int32(3)); err != nil {
|
||||||
// 인덱스가 방금 지워졌다.
|
return makeErrorWithStack(err)
|
||||||
// 전체 document 제거
|
|
||||||
logger.Println(mg.mongoClient.Collection(CollectionBlock).Drop(context))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionBlock, map[string]bson.D{
|
|
||||||
"accidend": {{Key: "accid", Value: 1}, {Key: "end", Value: 1}},
|
|
||||||
}); err != nil {
|
|
||||||
return logger.ErrorWithCallStack(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionPlatformLoginToken, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionPlatformLoginToken, map[string]bson.D{
|
||||||
"platformauthtoken": {{Key: "platform", Value: 1}, {Key: "key", Value: 1}},
|
"platformauthtoken": {{Key: "platform", Value: 1}, {Key: "key", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeExpireIndex(CollectionPlatformLoginToken, int32(config.SessionTTL+300)); err != nil {
|
if err = mg.mongoClient.MakeExpireIndex(CollectionPlatformLoginToken, int32(mg.SessionTTL+300)); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionUserToken, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionUserToken, map[string]bson.D{
|
||||||
"platformusertoken": {{Key: "platform", Value: 1}, {Key: "userid", Value: 1}},
|
"platformusertoken": {{Key: "platform", Value: 1}, {Key: "userid", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionGamepotUserInfo, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionGamepotUserInfo, map[string]bson.D{
|
||||||
"gamepotuserid": {{Key: "gamepotuserid", Value: 1}},
|
"gamepotuserid": {{Key: "gamepotuserid", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mg.mongoClient.MakeUniqueIndices(CollectionFirebaseUserInfo, map[string]bson.D{
|
if err = mg.mongoClient.MakeUniqueIndices(CollectionFirebaseUserInfo, map[string]bson.D{
|
||||||
"firebaseuserid": {{Key: "firebaseuserid", Value: 1}},
|
"firebaseuserid": {{Key: "firebaseuserid", Value: 1}},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mg.sessionProvider, err = session.NewProviderWithConfig(context, config.SessionConfig)
|
mg.auths = makeAuthCollection(mg.mongoClient, time.Duration(mg.SessionTTL*int64(time.Second)))
|
||||||
if err != nil {
|
|
||||||
return logger.ErrorWithCallStack(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var preall []struct {
|
var preall []struct {
|
||||||
Link string `bson:"link"`
|
Link string `bson:"link"`
|
||||||
@ -395,7 +414,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
|||||||
if err = mg.mongoClient.FindAllAs(CollectionFile, nil, &preall, options.Find().SetProjection(bson.M{
|
if err = mg.mongoClient.FindAllAs(CollectionFile, nil, &preall, options.Find().SetProjection(bson.M{
|
||||||
"link": 1,
|
"link": 1,
|
||||||
})); err != nil {
|
})); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pre := range preall {
|
for _, pre := range preall {
|
||||||
@ -410,40 +429,56 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
|||||||
"_id": pre.Id,
|
"_id": pre.Id,
|
||||||
}, &fulldoc)
|
}, &fulldoc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
err = fulldoc.Save()
|
err = fulldoc.Save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return makeErrorWithStack(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var whites []*whitelistmember
|
||||||
|
if err := mg.mongoClient.AllAs(CollectionWhitelist, &whites, options.Find().SetReturnKey(false)); err != nil {
|
||||||
|
return makeErrorWithStack(err)
|
||||||
|
}
|
||||||
|
mg.wl.init(whites)
|
||||||
|
|
||||||
|
var blocks []*blockinfo
|
||||||
|
if err := mg.mongoClient.AllAs(CollectionBlock, &blocks); err != nil {
|
||||||
|
return makeErrorWithStack(err)
|
||||||
|
}
|
||||||
|
mg.bl.init(blocks)
|
||||||
|
|
||||||
|
go watchAuthCollection(context, mg.auths, mg.mongoClient)
|
||||||
|
go mg.wl.watchCollection(context, CollectionWhitelist, mg.mongoClient)
|
||||||
|
go mg.bl.watchCollection(context, CollectionBlock, mg.mongoClient)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var portptr = flagx.Int("port", 80, "")
|
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error {
|
||||||
|
|
||||||
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) error {
|
|
||||||
var allServices []*serviceDescription
|
var allServices []*serviceDescription
|
||||||
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(allServices) > 0 {
|
if len(allServices) > 0 {
|
||||||
only := allServices[0]
|
only := allServices[0]
|
||||||
only.prepare(mg)
|
only.prepare(mg)
|
||||||
only.mustUseChecksum = config.MustUseChecksum
|
|
||||||
|
|
||||||
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 {
|
||||||
|
host, _ := os.Hostname()
|
||||||
addrs, err := net.InterfaceAddrs()
|
addrs, err := net.InterfaceAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
ipaddr := "127.0.0.1"
|
ipaddr := "127.0.0.1"
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
@ -455,15 +490,14 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.Serv
|
|||||||
}
|
}
|
||||||
|
|
||||||
empty.Divisions = map[string]*Division{
|
empty.Divisions = map[string]*Division{
|
||||||
"default": {
|
host: {
|
||||||
DivisionForUser: DivisionForUser{
|
DivisionForUser: DivisionForUser{
|
||||||
Priority: 0,
|
Priority: 0,
|
||||||
State: DivisionState_FullOpen,
|
State: DivisionState_FullOpen,
|
||||||
|
LockCreateChar: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
Urls: bson.M{
|
Url: fmt.Sprintf("http://%s/warehouse", ipaddr),
|
||||||
"warehouse": fmt.Sprintf("http://%s:%d/warehouse", ipaddr, *portptr),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -477,29 +511,21 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.Serv
|
|||||||
}, options.Update().SetUpsert(true))
|
}, options.Update().SetUpsert(true))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *devflag {
|
logger.Println("Service is registered :", mg.service().ServiceCode)
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "/"), func(w http.ResponseWriter, r *http.Request) {
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, mg.service().ServiceCode, "/"), func(w http.ResponseWriter, r *http.Request) {
|
||||||
// mg.service()를 요청마다 불러야 함
|
|
||||||
mg.service().serveHTTP_dev(w, r)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
pattern := gocommon.MakeHttpHandlerPattern(prefix, "/")
|
|
||||||
logger.Println("pattern registered :", pattern)
|
|
||||||
serveMux.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// mg.service()를 요청마다 불러야 함
|
|
||||||
mg.service().serveHTTP(w, r)
|
mg.service().serveHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "api/"), mg.api)
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "api/"), mg.api)
|
||||||
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "query/"), mg.query)
|
||||||
|
|
||||||
configraw, _ := json.Marshal(config)
|
configraw, _ := json.Marshal(mg.maingateConfig)
|
||||||
var convertedConfig map[string]any
|
var convertedConfig map[string]any
|
||||||
if err := json.Unmarshal(configraw, &convertedConfig); err != nil {
|
if err := json.Unmarshal(configraw, &convertedConfig); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "config"), func(w http.ResponseWriter, r *http.Request) {
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "config"), func(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -532,7 +558,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.Serv
|
|||||||
|
|
||||||
if err := os.MkdirAll("static", os.ModePerm); err != nil {
|
if err := os.MkdirAll("static", os.ModePerm); err != nil {
|
||||||
// 일반 엔드유저한테 오픈할 static 페이지
|
// 일반 엔드유저한테 오픈할 static 페이지
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cfsx := http.FileServer(http.Dir("console"))
|
cfsx := http.FileServer(http.Dir("console"))
|
||||||
@ -574,8 +600,6 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.Serv
|
|||||||
|
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformSteamSDK), mg.platform_steamsdk_authorize)
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformSteamSDK), mg.platform_steamsdk_authorize)
|
||||||
|
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_sdk", AuthPlatformHybeim), mg.platform_hybeim_authorize)
|
|
||||||
|
|
||||||
go mg.watchServiceCollection(ctx, serveMux, prefix)
|
go mg.watchServiceCollection(ctx, serveMux, prefix)
|
||||||
go mg.watchFileCollection(ctx, serveMux, prefix)
|
go mg.watchFileCollection(ctx, serveMux, prefix)
|
||||||
// fsx := http.FileServer(http.Dir("console"))
|
// fsx := http.FileServer(http.Dir("console"))
|
||||||
@ -585,11 +609,59 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.Serv
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mg *Maingate) query(w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer func() {
|
||||||
|
s := recover()
|
||||||
|
if s != nil {
|
||||||
|
logger.Error(s)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
io.Copy(io.Discard, r.Body)
|
||||||
|
r.Body.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
|
queryvals := r.URL.Query()
|
||||||
|
sk := queryvals.Get("sk")
|
||||||
|
|
||||||
|
if len(sk) == 0 {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
info := mg.auths.Find(sk)
|
||||||
|
if info == nil {
|
||||||
|
logger.Println("session key is not valid :", sk)
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !*devflag {
|
||||||
|
apitoken := r.Header.Get("MG-X-API-TOKEN")
|
||||||
|
if len(apitoken) == 0 {
|
||||||
|
logger.Println("MG-X-API-TOKEN is missing")
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
apitokenObj, _ := primitive.ObjectIDFromHex(apitoken)
|
||||||
|
if !mg.service().isValidToken(apitokenObj) {
|
||||||
|
logger.Println("MG-X-API-TOKEN is invalid :", apitoken)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bt, _ := json.Marshal(info)
|
||||||
|
w.Write(bt)
|
||||||
|
}
|
||||||
|
|
||||||
func (mg *Maingate) GeneratePlatformLoginNonceKey() string {
|
func (mg *Maingate) GeneratePlatformLoginNonceKey() string {
|
||||||
const allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
const allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
b := make([]byte, 52)
|
b := make([]byte, 52)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = allowed[r.Intn(len(allowed))]
|
b[i] = allowed[rand.Intn(len(allowed))]
|
||||||
}
|
}
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
@ -603,7 +675,7 @@ func (mg *Maingate) GetUserBrowserInfo(r *http.Request) (string, error) {
|
|||||||
|
|
||||||
cookie, err := r.Cookie("ActionSquareSessionExtraInfo")
|
cookie, err := r.Cookie("ActionSquareSessionExtraInfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", logger.ErrorWithCallStack(err)
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
//requestinfo := fmt.Sprintf("%s_%s", cookie.Value, host) //-- RemoteAddr체크는 로드밸런서 IP 찍히는 문제 때문에 제외한다.
|
//requestinfo := fmt.Sprintf("%s_%s", cookie.Value, host) //-- RemoteAddr체크는 로드밸런서 IP 찍히는 문제 때문에 제외한다.
|
||||||
@ -625,7 +697,7 @@ func (mg *Maingate) setUserToken(info usertokeninfo) error {
|
|||||||
"accesstoken_expire_time": info.accesstoken_expire_time,
|
"accesstoken_expire_time": info.accesstoken_expire_time,
|
||||||
},
|
},
|
||||||
}, options.Update().SetUpsert(true))
|
}, options.Update().SetUpsert(true))
|
||||||
return logger.ErrorWithCallStack(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) getUserTokenWithCheck(platform string, userid string, brinfo string) (usertokeninfo, error) {
|
func (mg *Maingate) getUserTokenWithCheck(platform string, userid string, brinfo string) (usertokeninfo, error) {
|
||||||
@ -650,7 +722,7 @@ func (mg *Maingate) getUserTokenWithCheck(platform string, userid string, brinfo
|
|||||||
|
|
||||||
updatetime, ok := found["lastupdate"].(int64)
|
updatetime, ok := found["lastupdate"].(int64)
|
||||||
|
|
||||||
if !ok || time.Now().Unix()-updatetime < config.Autologin_ttl {
|
if !ok || time.Now().Unix()-updatetime < mg.maingateConfig.Autologin_ttl {
|
||||||
info.platform = platform
|
info.platform = platform
|
||||||
info.userid = userid
|
info.userid = userid
|
||||||
info.brinfo = brinfo
|
info.brinfo = brinfo
|
||||||
@ -699,8 +771,6 @@ func (mg *Maingate) updateUserinfo(info usertokeninfo) (bool, string, string) {
|
|||||||
success, userid, email = mg.platform_google_getuserinfo(info)
|
success, userid, email = mg.platform_google_getuserinfo(info)
|
||||||
case AuthPlatformSteamSDK:
|
case AuthPlatformSteamSDK:
|
||||||
success, userid, email = mg.platform_steamsdk_getuserinfo(info)
|
success, userid, email = mg.platform_steamsdk_getuserinfo(info)
|
||||||
case AuthPlatformHybeim:
|
|
||||||
success, userid, email = mg.platform_hybeim_getuserinfo(info)
|
|
||||||
case AuthPlatformFirebaseAuth:
|
case AuthPlatformFirebaseAuth:
|
||||||
success, userid, email = mg.platform_firebase_getuserinfo(info)
|
success, userid, email = mg.platform_firebase_getuserinfo(info)
|
||||||
}
|
}
|
||||||
@ -741,14 +811,19 @@ func (mg *Maingate) getProviderInfo(platform string, uid string) (string, string
|
|||||||
if provider == "" || providerid == "" {
|
if provider == "" || providerid == "" {
|
||||||
return "", "", errors.New("getProviderInfo - firebase info not found: " + provider + " / " + providerid)
|
return "", "", errors.New("getProviderInfo - firebase info not found: " + provider + " / " + providerid)
|
||||||
}
|
}
|
||||||
|
case "":
|
||||||
|
//guest auth
|
||||||
|
providerid = uid
|
||||||
|
if providerid == "" {
|
||||||
|
return "", "", errors.New("getProviderInfo - guest provider id not found: " + provider + " / " + providerid)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
provider = platform
|
provider = platform
|
||||||
providerid = uid
|
providerid = uid
|
||||||
}
|
|
||||||
|
|
||||||
if provider == "" || providerid == "" {
|
if provider == "" || providerid == "" {
|
||||||
return "", "", errors.New("getProviderInfo - provider info not found: " + provider + " / " + providerid)
|
return "", "", errors.New("getProviderInfo - provider info not found: " + provider + " / " + providerid)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return provider, providerid, nil
|
return provider, providerid, nil
|
||||||
|
|
||||||
@ -911,16 +986,25 @@ func JWTparseCode(keyurl string, code string) (string, string, string) {
|
|||||||
return claims["sub"].(string), email, nonce
|
return claims["sub"].(string), email, nonce
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mg *Maingate) google_analytics_html(w http.ResponseWriter, r *http.Request) {
|
||||||
|
parsedTemplate, _ := template.ParseFiles("template/track-event.html")
|
||||||
|
err := parsedTemplate.Execute(w, nil)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Error executing template :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (mg *Maingate) google_analytics_js(w http.ResponseWriter, r *http.Request) {
|
func (mg *Maingate) google_analytics_js(w http.ResponseWriter, r *http.Request) {
|
||||||
fgaconfig := Firebase_Google_Analytics_JS_SDK_Config{
|
fgaconfig := Firebase_Google_Analytics_JS_SDK_Config{
|
||||||
FGA_apiKey: config.FGA_apiKey,
|
FGA_apiKey: mg.FGA_apiKey,
|
||||||
FGA_authDomain: config.FGA_authDomain,
|
FGA_authDomain: mg.FGA_authDomain,
|
||||||
FGA_databaseURL: config.FGA_databaseURL,
|
FGA_databaseURL: mg.FGA_databaseURL,
|
||||||
FGA_projectId: config.FGA_projectId,
|
FGA_projectId: mg.FGA_projectId,
|
||||||
FGA_storageBucket: config.FGA_storageBucket,
|
FGA_storageBucket: mg.FGA_storageBucket,
|
||||||
FGA_messagingSenderId: config.FGA_messagingSenderId,
|
FGA_messagingSenderId: mg.FGA_messagingSenderId,
|
||||||
FGA_appId: config.FGA_appId,
|
FGA_appId: mg.FGA_appId,
|
||||||
FGA_measurementId: config.FGA_measurementId,
|
FGA_measurementId: mg.FGA_measurementId,
|
||||||
}
|
}
|
||||||
parsedTemplate, _ := template.ParseFiles("template/fb-ga.min.js")
|
parsedTemplate, _ := template.ParseFiles("template/fb-ga.min.js")
|
||||||
err := parsedTemplate.Execute(w, fgaconfig)
|
err := parsedTemplate.Execute(w, fgaconfig)
|
||||||
|
|||||||
177
core/member_container.go
Normal file
177
core/member_container.go
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
type memberContraints[K comparable] interface {
|
||||||
|
Key() K
|
||||||
|
Expired() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type memberContainerPtr[K comparable, T memberContraints[K]] struct {
|
||||||
|
ptr unsafe.Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) init(ms []T) {
|
||||||
|
next := map[K]T{}
|
||||||
|
for _, m := range ms {
|
||||||
|
next[m.Key()] = m
|
||||||
|
}
|
||||||
|
atomic.StorePointer(&p.ptr, unsafe.Pointer(&next))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) add(m T) {
|
||||||
|
ptr := atomic.LoadPointer(&p.ptr)
|
||||||
|
src := (*map[K]T)(ptr)
|
||||||
|
|
||||||
|
next := map[K]T{}
|
||||||
|
for k, v := range *src {
|
||||||
|
next[k] = v
|
||||||
|
}
|
||||||
|
next[m.Key()] = m
|
||||||
|
atomic.StorePointer(&p.ptr, unsafe.Pointer(&next))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) get(key K) (T, bool) {
|
||||||
|
ptr := atomic.LoadPointer(&p.ptr)
|
||||||
|
src := (*map[K]T)(ptr)
|
||||||
|
|
||||||
|
out, found := (*src)[key]
|
||||||
|
return out, found
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) remove(key K) {
|
||||||
|
ptr := atomic.LoadPointer(&p.ptr)
|
||||||
|
src := (*map[K]T)(ptr)
|
||||||
|
|
||||||
|
next := map[K]T{}
|
||||||
|
for k, v := range *src {
|
||||||
|
next[k] = v
|
||||||
|
}
|
||||||
|
delete(next, key)
|
||||||
|
atomic.StorePointer(&p.ptr, unsafe.Pointer(&next))
|
||||||
|
}
|
||||||
|
|
||||||
|
type memberPipelineDocument[K comparable, T memberContraints[K]] struct {
|
||||||
|
OperationType string `bson:"operationType"`
|
||||||
|
DocumentKey struct {
|
||||||
|
Id primitive.ObjectID `bson:"_id"`
|
||||||
|
} `bson:"documentKey"`
|
||||||
|
Member T `bson:"fullDocument"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) all() []T {
|
||||||
|
ptr := atomic.LoadPointer(&p.ptr)
|
||||||
|
src := (*map[K]T)(ptr)
|
||||||
|
|
||||||
|
out := make([]T, 0, len(*src))
|
||||||
|
for _, m := range *src {
|
||||||
|
if m.Expired() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out = append(out, m)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) contains(key K, out *T) bool {
|
||||||
|
ptr := atomic.LoadPointer(&p.ptr)
|
||||||
|
src := (*map[K]T)(ptr)
|
||||||
|
|
||||||
|
found, exists := (*src)[key]
|
||||||
|
if exists {
|
||||||
|
if found.Expired() {
|
||||||
|
p.remove(key)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if out != nil {
|
||||||
|
*out = found
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *memberContainerPtr[K, T]) watchCollection(parentctx context.Context, coll gocommon.CollectionName, mc gocommon.MongoClient) {
|
||||||
|
defer func() {
|
||||||
|
s := recover()
|
||||||
|
if s != nil {
|
||||||
|
logger.Error(s)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
matchStage := bson.D{
|
||||||
|
{
|
||||||
|
Key: "$match", Value: bson.D{
|
||||||
|
{Key: "operationType", Value: bson.D{
|
||||||
|
{Key: "$in", Value: bson.A{
|
||||||
|
"update",
|
||||||
|
"insert",
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
projectStage := bson.D{
|
||||||
|
{
|
||||||
|
Key: "$project", Value: bson.D{
|
||||||
|
{Key: "documentKey", Value: 1},
|
||||||
|
{Key: "fullDocument", Value: 1},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var stream *mongo.ChangeStream
|
||||||
|
var err error
|
||||||
|
var ctx context.Context
|
||||||
|
|
||||||
|
for {
|
||||||
|
if stream == nil {
|
||||||
|
stream, err = mc.Watch(coll, mongo.Pipeline{matchStage, projectStage})
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("watchCollection watch failed :", err)
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ctx = context.TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
changed := stream.TryNext(ctx)
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
logger.Error("watchCollection stream.TryNext failed. process should be restarted! :", ctx.Err().Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if changed {
|
||||||
|
var data memberPipelineDocument[K, T]
|
||||||
|
if err := stream.Decode(&data); err == nil {
|
||||||
|
p.add(data.Member)
|
||||||
|
} else {
|
||||||
|
logger.Error("watchCollection stream.Decode failed :", err)
|
||||||
|
}
|
||||||
|
} else if stream.Err() != nil || stream.ID() == 0 {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
logger.Println("watchCollection is done")
|
||||||
|
stream.Close(ctx)
|
||||||
|
return
|
||||||
|
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
logger.Error("watchCollection stream error :", stream.Err())
|
||||||
|
stream.Close(ctx)
|
||||||
|
stream = nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -95,8 +95,8 @@ func (mg *Maingate) platform_apple_get_login_url(w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.AppleCientId)
|
params.Add("client_id", mg.AppleCientId)
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformApple)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformApple)
|
||||||
|
|
||||||
params.Add("response_type", "code id_token")
|
params.Add("response_type", "code id_token")
|
||||||
params.Add("scope", "name email")
|
params.Add("scope", "name email")
|
||||||
@ -146,7 +146,7 @@ func (mg *Maingate) platform_apple_authorize(w http.ResponseWriter, r *http.Requ
|
|||||||
}
|
}
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformApple, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformApple, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *http.Request) {
|
func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -208,17 +208,17 @@ func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *ht
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the client secret used to authenticate with Apple's validation servers
|
// Generate the client secret used to authenticate with Apple's validation servers
|
||||||
secret, err := generateClientSecret(config.ApplePrivateKey, config.AppleTeamId, config.AppleServiceId, config.AppleKeyId)
|
secret, err := generateClientSecret(mg.ApplePrivateKey, mg.AppleTeamId, mg.AppleServiceId, mg.AppleKeyId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error generating secret: ", err)
|
logger.Error("error generating secret: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vReq := Apple_WebValidationTokenRequest{
|
vReq := Apple_WebValidationTokenRequest{
|
||||||
ClientID: config.AppleServiceId,
|
ClientID: mg.AppleServiceId,
|
||||||
ClientSecret: secret,
|
ClientSecret: secret,
|
||||||
Code: code,
|
Code: code,
|
||||||
RedirectURI: config.RedirectBaseUrl + "/authorize/" + AuthPlatformApple, // This URL must be validated with apple in your service
|
RedirectURI: mg.RedirectBaseUrl + "/authorize/" + AuthPlatformApple, // This URL must be validated with apple in your service
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp Apple_ValidationResponse
|
var resp Apple_ValidationResponse
|
||||||
@ -268,14 +268,14 @@ func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *ht
|
|||||||
|
|
||||||
func (mg *Maingate) platform_apple_getuserinfo(refreshToken string) (bool, string, string) {
|
func (mg *Maingate) platform_apple_getuserinfo(refreshToken string) (bool, string, string) {
|
||||||
//=================================RefreshToken을 사용해서 정보 가져 온다. 이미 인증된 사용자의 업데이트 목적
|
//=================================RefreshToken을 사용해서 정보 가져 온다. 이미 인증된 사용자의 업데이트 목적
|
||||||
secret, err := generateClientSecret(config.ApplePrivateKey, config.AppleTeamId, config.AppleServiceId, config.AppleKeyId)
|
secret, err := generateClientSecret(mg.ApplePrivateKey, mg.AppleTeamId, mg.AppleServiceId, mg.AppleKeyId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error generating secret: ", err)
|
logger.Error("error generating secret: ", err)
|
||||||
return false, "", ""
|
return false, "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
vReqRefreshToken := Apple_WebRefreshTokenRequest{
|
vReqRefreshToken := Apple_WebRefreshTokenRequest{
|
||||||
ClientID: config.AppleServiceId,
|
ClientID: mg.AppleServiceId,
|
||||||
ClientSecret: secret,
|
ClientSecret: secret,
|
||||||
RefreshToken: refreshToken,
|
RefreshToken: refreshToken,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package core
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -147,11 +146,6 @@ func (mg *Maingate) platform_firebaseauth_authorize_sdk(w http.ResponseWriter, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_firebaseauth_authorize_raw(w http.ResponseWriter, brinfo, code, state, cookieSessionKey, memberId, nickname, provider, providerId, email, photourl, phonenumber string) (bool, string) {
|
func (mg *Maingate) platform_firebaseauth_authorize_raw(w http.ResponseWriter, brinfo, code, state, cookieSessionKey, memberId, nickname, provider, providerId, email, photourl, phonenumber string) (bool, string) {
|
||||||
if mg.firebase == nil {
|
|
||||||
logger.Println("mg.firebase is nil. check 'firebase_admin_sdk_credentialfile' config or 'authtype' parameter")
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return false, ""
|
|
||||||
}
|
|
||||||
|
|
||||||
found, err := mg.mongoClient.FindOne(CollectionPlatformLoginToken, bson.M{
|
found, err := mg.mongoClient.FindOne(CollectionPlatformLoginToken, bson.M{
|
||||||
"platform": AuthPlatformFirebaseAuth,
|
"platform": AuthPlatformFirebaseAuth,
|
||||||
@ -194,7 +188,7 @@ func (mg *Maingate) platform_firebaseauth_authorize_raw(w http.ResponseWriter, b
|
|||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = mg.firebase.firebaseAppClient.VerifyIDToken(mg.firebase.firebaseAppContext, code)
|
_, err = mg.firebaseAppClient.VerifyIDToken(mg.firebaseAppContext, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error verifying ID token:", err)
|
log.Println("error verifying ID token:", err)
|
||||||
return false, ""
|
return false, ""
|
||||||
@ -248,10 +242,6 @@ func (mg *Maingate) platform_firebaseauth_authorize_raw(w http.ResponseWriter, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_firebase_getuserinfo(info usertokeninfo) (bool, string, string) {
|
func (mg *Maingate) platform_firebase_getuserinfo(info usertokeninfo) (bool, string, string) {
|
||||||
if mg.firebase == nil {
|
|
||||||
logger.Println("mg.firebase is nil. check 'firebase_admin_sdk_credentialfile' config or 'authtype' parameter")
|
|
||||||
return false, "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
found, err := mg.mongoClient.FindOne(CollectionFirebaseUserInfo, bson.M{
|
found, err := mg.mongoClient.FindOne(CollectionFirebaseUserInfo, bson.M{
|
||||||
"firebaseuserid": info.userid,
|
"firebaseuserid": info.userid,
|
||||||
@ -266,16 +256,13 @@ func (mg *Maingate) platform_firebase_getuserinfo(info usertokeninfo) (bool, str
|
|||||||
return false, "", ""
|
return false, "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = mg.firebase.firebaseAppClient.VerifyIDToken(mg.firebase.firebaseAppContext, info.token)
|
_, err = mg.firebaseAppClient.VerifyIDToken(mg.firebaseAppContext, info.token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error verifying ID token:", err)
|
log.Println("error verifying ID token:", err)
|
||||||
return false, "", ""
|
return false, "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
tempEmail := found["firebaseemail"].(string)
|
tempEmail := found["firebaseemail"].(string)
|
||||||
if found["firebaseprovider"].(string) == "guest" {
|
|
||||||
tempEmail = fmt.Sprintf("%s@guest.flag", info.userid)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, info.userid, tempEmail
|
return true, info.userid, tempEmail
|
||||||
|
|
||||||
|
|||||||
@ -84,9 +84,9 @@ func (mg *Maingate) platform_google_get_login_url(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.GoogleClientId)
|
params.Add("client_id", mg.GoogleClientId)
|
||||||
params.Add("response_type", "code")
|
params.Add("response_type", "code")
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
||||||
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
|
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
|
||||||
params.Add("access_type", "offline")
|
params.Add("access_type", "offline")
|
||||||
params.Add("prompt", "consent")
|
params.Add("prompt", "consent")
|
||||||
@ -140,7 +140,7 @@ func (mg *Maingate) platform_google_authorize(w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
http.SetCookie(w, &cookie2)
|
http.SetCookie(w, &cookie2)
|
||||||
|
|
||||||
http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformGoogle, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformGoogle, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *http.Request) {
|
func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -211,9 +211,9 @@ func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *h
|
|||||||
|
|
||||||
//=================
|
//=================
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.GoogleClientId)
|
params.Add("client_id", mg.GoogleClientId)
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
||||||
params.Add("client_secret", config.GoogleClientSecret)
|
params.Add("client_secret", mg.GoogleClientSecret)
|
||||||
params.Add("code", code)
|
params.Add("code", code)
|
||||||
params.Add("grant_type", "authorization_code")
|
params.Add("grant_type", "authorization_code")
|
||||||
|
|
||||||
@ -285,9 +285,9 @@ func (mg *Maingate) platform_google_getuserinfo(info usertokeninfo) (bool, strin
|
|||||||
if time.Now().Unix() > info.accesstoken_expire_time {
|
if time.Now().Unix() > info.accesstoken_expire_time {
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.GoogleClientId)
|
params.Add("client_id", mg.GoogleClientId)
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformGoogle)
|
||||||
params.Add("client_secret", config.GoogleClientSecret)
|
params.Add("client_secret", mg.GoogleClientSecret)
|
||||||
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
|
params.Add("scope", "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
|
||||||
params.Add("refresh_token", info.token)
|
params.Add("refresh_token", info.token)
|
||||||
params.Add("grant_type", "refresh_token")
|
params.Add("grant_type", "refresh_token")
|
||||||
|
|||||||
@ -1,198 +0,0 @@
|
|||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
type HybeImSDKAuthInfo struct {
|
|
||||||
UserHybeimid string `json:"imid"`
|
|
||||||
UserLoginVerifyToken string `json:"loginVerifyToken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HybeImSDKLoginAuthInfo struct {
|
|
||||||
ServiceId string `json:"serviceId"`
|
|
||||||
UserLoginVerifyToken string `json:"loginVerifyToken"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Hiveim_LoginVerifyResult struct {
|
|
||||||
State string `json:"state"`
|
|
||||||
ImId string `json:"imId"`
|
|
||||||
Provider string `json:"provider"`
|
|
||||||
Os string `json:"os"`
|
|
||||||
AppStore string `json:"appStore"`
|
|
||||||
UserBlockInfo []Hiveim_UserBlockInfo `json:"blocks"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Hiveim_UserBlockInfo struct {
|
|
||||||
BlockId int `json:"blockId"`
|
|
||||||
ReasonId int `json:"reasonId"`
|
|
||||||
BlockedAt int64 `json:"blockedAt"`
|
|
||||||
ExpireAt int64 `json:"expireAt"`
|
|
||||||
Permanent bool `json:"permanent"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Hiveim_LoginValidationResponse struct {
|
|
||||||
ResultCode string `json:"resultCode"`
|
|
||||||
ResultMessage string `json:"resultMessage"`
|
|
||||||
ResultData Hiveim_LoginVerifyResult `json:"resultData"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mg *Maingate) platform_hybeim_authorize(w http.ResponseWriter, r *http.Request) {
|
|
||||||
defer r.Body.Close()
|
|
||||||
|
|
||||||
brinfo, err := mg.GetUserBrowserInfo(r)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
logger.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var authinfo HybeImSDKAuthInfo
|
|
||||||
err = json.NewDecoder(r.Body).Decode(&authinfo)
|
|
||||||
if err != nil {
|
|
||||||
logger.Println("authinfo decoding fail:", err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var resultcode string
|
|
||||||
var blockinfo Hiveim_UserBlockInfo
|
|
||||||
if !*noauth {
|
|
||||||
err, resultcode, blockinfo = authenticateHybeImUser(config.HybeImProjectIdstring, config.HybeImServiceIdstring, config.HybeImAccessKey, config.HybeImEndPoint, authinfo.UserHybeimid, authinfo.UserLoginVerifyToken)
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://hybeim.gitbook.io/im-assemble/api/im-assemble-s2s-api#login-verify
|
|
||||||
// SUCCESS : 성공
|
|
||||||
// INVALID_LOGIN_VERIFY_TOKEN : login 인증 토큰 오류
|
|
||||||
// LOGIN_VERIFY_EXPIRED : login 인증 토큰 만료
|
|
||||||
// INVALID_SERVICE_ID : 유효 하지 않은 서비스 id
|
|
||||||
// WITHDRAWAL_ACCOUNT : 탈퇴 대기 상태 유저
|
|
||||||
// RELOGIN_REQUIRED : 로그인 데이터에 문제가 있어 다시 로그인 해야 되는 경우
|
|
||||||
// INTERNAL_SERVER_ERROR : 서버 오류
|
|
||||||
|
|
||||||
if err == nil && resultcode == "SUCCESS" {
|
|
||||||
acceestoken_expire_time := time.Date(2999, 1, int(time.January), 0, 0, 0, 0, time.UTC).Unix()
|
|
||||||
|
|
||||||
var info usertokeninfo
|
|
||||||
info.platform = AuthPlatformHybeim
|
|
||||||
info.userid = authinfo.UserHybeimid
|
|
||||||
info.token = authinfo.UserLoginVerifyToken
|
|
||||||
info.brinfo = brinfo
|
|
||||||
//info.accesstoken = respReferesh.AccessToken
|
|
||||||
info.accesstoken_expire_time = acceestoken_expire_time
|
|
||||||
mg.setUserToken(info)
|
|
||||||
|
|
||||||
params := url.Values{}
|
|
||||||
params.Add("id", authinfo.UserHybeimid)
|
|
||||||
params.Add("authtype", AuthPlatformHybeim)
|
|
||||||
w.Write([]byte("?" + params.Encode()))
|
|
||||||
//http.Redirect(w, r, "actionsquare://login?"+Result, http.StatusSeeOther)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
params := url.Values{}
|
|
||||||
params.Add("resultcode", resultcode)
|
|
||||||
if resultcode == "BLOCKED" {
|
|
||||||
blockinfoBytes, _ := json.Marshal(blockinfo)
|
|
||||||
blockinfostr := string(blockinfoBytes)
|
|
||||||
params.Add("blockinfo", blockinfostr)
|
|
||||||
}
|
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
|
||||||
w.Write([]byte("?" + params.Encode()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// logger.Println(err)
|
|
||||||
// http.Redirect(w, r, "actionsquare://error", http.StatusSeeOther)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func authenticateHybeImUser(projectid, serviceid, accesskey, endpoint, imid, UserLoginVerifyToken string) (error, string, Hiveim_UserBlockInfo) {
|
|
||||||
|
|
||||||
// endpoint
|
|
||||||
// qa = https://api-qa.pub-dev.hybegames.io
|
|
||||||
// prod = https://api.hybegames.com
|
|
||||||
|
|
||||||
verifyurl := endpoint + "/member/api-game/v1/auth/login/verify"
|
|
||||||
|
|
||||||
var param HybeImSDKLoginAuthInfo
|
|
||||||
param.UserLoginVerifyToken = UserLoginVerifyToken
|
|
||||||
param.ServiceId = serviceid
|
|
||||||
|
|
||||||
dat, err := json.Marshal(param)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var respReferesh Hiveim_LoginValidationResponse
|
|
||||||
req, err := http.NewRequest("POST", verifyurl, bytes.NewBuffer(dat))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Add("X-Auth-Access-Key", accesskey)
|
|
||||||
req.Header.Add("X-Req-Pjid", projectid)
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
io.Copy(io.Discard, resp.Body)
|
|
||||||
resp.Body.Close()
|
|
||||||
}()
|
|
||||||
|
|
||||||
var blockinfo Hiveim_UserBlockInfo
|
|
||||||
body, e := ioutil.ReadAll(resp.Body)
|
|
||||||
if e != nil {
|
|
||||||
return e, "", blockinfo
|
|
||||||
}
|
|
||||||
|
|
||||||
json.Unmarshal(body, &respReferesh)
|
|
||||||
|
|
||||||
//fmt.Println(string(body))
|
|
||||||
|
|
||||||
var doc map[string]interface{}
|
|
||||||
if err := json.Unmarshal(body, &doc); err != nil {
|
|
||||||
return err, respReferesh.ResultCode, blockinfo
|
|
||||||
}
|
|
||||||
|
|
||||||
// if respReferesh.ResultData.State != "NORMAL" {
|
|
||||||
// return errors.New("higveimSDK: State is not NORMAL"), respReferesh.ResultCode, blockinfo
|
|
||||||
// }
|
|
||||||
|
|
||||||
if respReferesh.ResultData.Provider != "STEAM" {
|
|
||||||
return errors.New("higveimSDK: Provider is not STEAM"), respReferesh.ResultCode, blockinfo
|
|
||||||
}
|
|
||||||
|
|
||||||
if respReferesh.ResultData.ImId != imid {
|
|
||||||
return errors.New("higveimSDK: ImId is not match"), respReferesh.ResultCode, blockinfo
|
|
||||||
}
|
|
||||||
|
|
||||||
if respReferesh.ResultCode == "SUCCESS" {
|
|
||||||
if respReferesh.ResultData.State == "BLOCKED" && len(respReferesh.ResultData.UserBlockInfo) > 0 {
|
|
||||||
blockinfo = respReferesh.ResultData.UserBlockInfo[0]
|
|
||||||
return nil, "BLOCKED", blockinfo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, respReferesh.ResultCode, blockinfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mg *Maingate) platform_hybeim_getuserinfo(info usertokeninfo) (bool, string, string) {
|
|
||||||
// Hybeim ( Steam )도 이메일 정보를 받을수 없기 때문에 userid로 리턴한다.
|
|
||||||
dummyEmail := fmt.Sprintf("%s@hibeim.id", info.userid)
|
|
||||||
return true, info.userid, dummyEmail
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -83,9 +83,9 @@ func (mg *Maingate) platform_microsoft_get_login_url(w http.ResponseWriter, r *h
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.MicrosoftClientId)
|
params.Add("client_id", mg.MicrosoftClientId)
|
||||||
params.Add("response_type", "code")
|
params.Add("response_type", "code")
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
||||||
params.Add("response_mode", "query")
|
params.Add("response_mode", "query")
|
||||||
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ func (mg *Maingate) platform_microsoft_authorize(w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformMicrosoft, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformMicrosoft, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r *http.Request) {
|
func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -191,13 +191,13 @@ func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r
|
|||||||
//=================
|
//=================
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.MicrosoftClientId)
|
params.Add("client_id", mg.MicrosoftClientId)
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
||||||
params.Add("code", code)
|
params.Add("code", code)
|
||||||
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
||||||
params.Add("grant_type", "authorization_code")
|
params.Add("grant_type", "authorization_code")
|
||||||
|
|
||||||
params.Add("client_secret", config.MicrosoftClientSecret)
|
params.Add("client_secret", mg.MicrosoftClientSecret)
|
||||||
|
|
||||||
var respReferesh Microsoft_ValidationResponse
|
var respReferesh Microsoft_ValidationResponse
|
||||||
acceestoken_expire_time := time.Now().Unix()
|
acceestoken_expire_time := time.Now().Unix()
|
||||||
@ -263,13 +263,13 @@ func (mg *Maingate) platform_microsoft_getuserinfo(info usertokeninfo) (bool, st
|
|||||||
if time.Now().Unix() > info.accesstoken_expire_time {
|
if time.Now().Unix() > info.accesstoken_expire_time {
|
||||||
|
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Add("client_id", config.MicrosoftClientId)
|
params.Add("client_id", mg.MicrosoftClientId)
|
||||||
params.Add("redirect_uri", config.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
params.Add("redirect_uri", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformMicrosoft)
|
||||||
params.Add("refresh_token", info.token)
|
params.Add("refresh_token", info.token)
|
||||||
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
params.Add("scope", "openid offline_access https://graph.microsoft.com/mail.read")
|
||||||
params.Add("grant_type", "refresh_token")
|
params.Add("grant_type", "refresh_token")
|
||||||
|
|
||||||
params.Add("client_secret", config.MicrosoftClientSecret)
|
params.Add("client_secret", mg.MicrosoftClientSecret)
|
||||||
|
|
||||||
var respReferesh Microsoft_ValidationResponse
|
var respReferesh Microsoft_ValidationResponse
|
||||||
acceestoken_expire_time := time.Now().Unix()
|
acceestoken_expire_time := time.Now().Unix()
|
||||||
|
|||||||
@ -39,7 +39,11 @@ func (mg *Maingate) platform_steamsdk_authorize(w http.ResponseWriter, r *http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authenticateSteamUser(config.SteamPublisherAuthKey, config.SteamAppId, authinfo.UserSteamId, authinfo.UserAuthToken); err == nil {
|
if !*noauth {
|
||||||
|
err = authenticateSteamUser(mg.SteamPublisherAuthKey, mg.SteamAppId, authinfo.UserSteamId, authinfo.UserAuthToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
acceestoken_expire_time := time.Date(2999, 1, int(time.January), 0, 0, 0, 0, time.UTC).Unix()
|
acceestoken_expire_time := time.Date(2999, 1, int(time.January), 0, 0, 0, 0, time.UTC).Unix()
|
||||||
|
|
||||||
var info usertokeninfo
|
var info usertokeninfo
|
||||||
@ -114,8 +118,9 @@ func authenticateSteamUser(pubkey, appid, playerid, ticket string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_steamsdk_getuserinfo(info usertokeninfo) (bool, string, string) {
|
func (mg *Maingate) platform_steamsdk_getuserinfo(info usertokeninfo) (bool, string, string) {
|
||||||
// Steam은 이메일 정보를 받을수 없기 때문에 userid로 리턴한다.
|
|
||||||
dummyEmail := fmt.Sprintf("%s@steam.id", info.userid)
|
// Steam은 이메일 정보를 받을수 없기 때문에 dummy임시 주소 할당하여 리턴한다.
|
||||||
|
dummyEmail := fmt.Sprintf("__dummy_%s@steamtemp__", info.userid)
|
||||||
return true, info.userid, dummyEmail
|
return true, info.userid, dummyEmail
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,7 +123,7 @@ func (mg *Maingate) platform_twitter_authorize(w http.ResponseWriter, r *http.Re
|
|||||||
}
|
}
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
http.Redirect(w, r, config.RedirectBaseUrl+"/authorize_result/"+AuthPlatformTwitter, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
http.Redirect(w, r, mg.RedirectBaseUrl+"/authorize_result/"+AuthPlatformTwitter, http.StatusSeeOther) //-- 바로 받으니까 쿠키 안와서 한번 더 Redirect 시킨다.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_twitter_authorize_result(w http.ResponseWriter, r *http.Request) {
|
func (mg *Maingate) platform_twitter_authorize_result(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -249,7 +249,7 @@ func (mg *Maingate) platform_twitter_getuserinfo(token, secret string) (bool, st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) CallTwitterAPI_WithAPPKey(requesturl, method, nonce string) string {
|
func (mg *Maingate) CallTwitterAPI_WithAPPKey(requesturl, method, nonce string) string {
|
||||||
return mg.CallTwitterAPI(requesturl, method, config.TwitterOAuthKey, config.TwitterOAuthSecret, nonce)
|
return mg.CallTwitterAPI(requesturl, method, mg.TwitterOAuthKey, mg.TwitterOAuthSecret, nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret, nonce string) string {
|
func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret, nonce string) string {
|
||||||
@ -272,8 +272,8 @@ func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret
|
|||||||
//vals.Add("oauth_callback", "actionclient://callback")
|
//vals.Add("oauth_callback", "actionclient://callback")
|
||||||
//vals.Add("oauth_callback", "http://127.0.0.1:7770/auth")
|
//vals.Add("oauth_callback", "http://127.0.0.1:7770/auth")
|
||||||
|
|
||||||
vals.Add("oauth_callback", config.RedirectBaseUrl+"/authorize/"+AuthPlatformTwitter)
|
vals.Add("oauth_callback", mg.RedirectBaseUrl+"/authorize/"+AuthPlatformTwitter)
|
||||||
vals.Add("oauth_consumer_key", config.TwitterCustomerKey)
|
vals.Add("oauth_consumer_key", mg.TwitterCustomerKey)
|
||||||
vals.Add("oauth_token", oauth_token)
|
vals.Add("oauth_token", oauth_token)
|
||||||
vals.Add("oauth_signature_method", "HMAC-SHA1")
|
vals.Add("oauth_signature_method", "HMAC-SHA1")
|
||||||
vals.Add("oauth_timestamp", strconv.Itoa(int(time.Now().Unix())))
|
vals.Add("oauth_timestamp", strconv.Itoa(int(time.Now().Unix())))
|
||||||
@ -282,7 +282,7 @@ func (mg *Maingate) CallTwitterAPI(requesturl, method, oauth_token, oauth_secret
|
|||||||
|
|
||||||
parameterString := strings.Replace(vals.Encode(), "+", "%20", -1)
|
parameterString := strings.Replace(vals.Encode(), "+", "%20", -1)
|
||||||
signatureBase := strings.ToUpper(method) + "&" + url.QueryEscape(strings.Split(requesturl, "?")[0]) + "&" + url.QueryEscape(parameterString)
|
signatureBase := strings.ToUpper(method) + "&" + url.QueryEscape(strings.Split(requesturl, "?")[0]) + "&" + url.QueryEscape(parameterString)
|
||||||
signingKey := url.QueryEscape(config.TwitterCustomerSecret) + "&" + url.QueryEscape(oauth_secret)
|
signingKey := url.QueryEscape(mg.TwitterCustomerSecret) + "&" + url.QueryEscape(oauth_secret)
|
||||||
signature := calculateTwitterSignature(signatureBase, signingKey)
|
signature := calculateTwitterSignature(signatureBase, signingKey)
|
||||||
|
|
||||||
headerString := "OAuth oauth_callback=\"" + url.QueryEscape(vals.Get("oauth_callback")) + "\", oauth_consumer_key=\"" + url.QueryEscape(vals.Get("oauth_consumer_key")) + "\", oauth_nonce=\"" + url.QueryEscape(vals.Get("oauth_nonce")) +
|
headerString := "OAuth oauth_callback=\"" + url.QueryEscape(vals.Get("oauth_callback")) + "\", oauth_consumer_key=\"" + url.QueryEscape(vals.Get("oauth_consumer_key")) + "\", oauth_nonce=\"" + url.QueryEscape(vals.Get("oauth_nonce")) +
|
||||||
|
|||||||
565
core/service.go
565
core/service.go
@ -1,7 +1,6 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@ -14,7 +13,6 @@ import (
|
|||||||
|
|
||||||
"repositories.action2quare.com/ayo/gocommon"
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
"repositories.action2quare.com/ayo/gocommon/session"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
@ -22,23 +20,33 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type blockinfo struct {
|
type blockinfo struct {
|
||||||
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
|
||||||
Start primitive.DateTime `bson:"start" json:"start"`
|
Start primitive.DateTime `bson:"start" json:"start"`
|
||||||
End primitive.DateTime `bson:"end" json:"end"`
|
End primitive.DateTime `bson:"_ts" json:"_ts"`
|
||||||
Accid primitive.ObjectID `bson:"accid,omitempty" json:"accid,omitempty"`
|
Reason string `bson:"reason" json:"reason"`
|
||||||
Meta primitive.M `bson:"meta,omitempty" json:"meta,omitempty"`
|
Accid primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type blockinfoWithStringId struct {
|
||||||
|
Reason string `bson:"reason" json:"reason"`
|
||||||
|
StrId string `bson:"id" json:"id"`
|
||||||
|
StartUnix int64 `bson:"start_unix" json:"start_unix"`
|
||||||
|
EndUnix int64 `bson:"end_unix" json:"end_unix"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type whitelistmember struct {
|
type whitelistmember struct {
|
||||||
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
Id primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
|
||||||
Alias string `bson:"alias" json:"alias"`
|
Email string `bson:"email" json:"email"`
|
||||||
Platform string `bson:"platform" json:"platform"`
|
Platform string `bson:"platform" json:"platform"`
|
||||||
Desc string `bson:"desc" json:"desc"`
|
Desc string `bson:"desc" json:"desc"`
|
||||||
ExpiredAt primitive.DateTime `bson:"_ts,omitempty" json:"_ts,omitempty"`
|
ExpiredAt primitive.DateTime `bson:"_ts,omitempty" json:"_ts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wh *whitelistmember) Key() string {
|
func (wh *whitelistmember) Key() string {
|
||||||
return wh.Alias
|
if strings.HasPrefix(wh.Email, "*@") {
|
||||||
|
// 도메인 전체 허용
|
||||||
|
return wh.Email[2:]
|
||||||
|
}
|
||||||
|
return wh.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wh *whitelistmember) Expired() bool {
|
func (wh *whitelistmember) Expired() bool {
|
||||||
@ -82,27 +90,34 @@ type Maintenance struct {
|
|||||||
type DivisionForUser struct {
|
type DivisionForUser struct {
|
||||||
Priority int `bson:"priority" json:"priority"`
|
Priority int `bson:"priority" json:"priority"`
|
||||||
State DivisionStateName `bson:"state" json:"state"`
|
State DivisionStateName `bson:"state" json:"state"`
|
||||||
|
LockCreateChar bool `bson:"lockcreatechar" json:"lockcreatechar"`
|
||||||
Maintenance *Maintenance `bson:"maintenance,omitempty" json:"maintenance,omitempty"`
|
Maintenance *Maintenance `bson:"maintenance,omitempty" json:"maintenance,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Division struct {
|
type Division struct {
|
||||||
DivisionForUser `bson:",inline" json:",inline"`
|
DivisionForUser `bson:",inline" json:",inline"`
|
||||||
Url_Deprecated string `bson:"url" json:"url"`
|
Url string `bson:"url" json:"url"`
|
||||||
Urls bson.M `bson:"urls" json:"urls"`
|
}
|
||||||
urlsSerialized []byte
|
|
||||||
|
type ServiceDescriptionSummary struct {
|
||||||
|
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
||||||
|
ServiceCode string `bson:"code" json:"code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceDescription struct {
|
type serviceDescription struct {
|
||||||
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
ServiceDescriptionSummary `bson:",inline" json:",inline"`
|
||||||
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
|
||||||
VersionSplits map[string]string `bson:"version_splits" json:"version_splits"`
|
VersionSplits map[string]string `bson:"version_splits" json:"version_splits"`
|
||||||
|
|
||||||
sessionProvider session.Provider
|
auths *gocommon.AuthCollection
|
||||||
|
wl *memberContainerPtr[string, *whitelistmember]
|
||||||
|
bl *memberContainerPtr[primitive.ObjectID, *blockinfo]
|
||||||
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)
|
||||||
@ -111,7 +126,6 @@ type serviceDescription struct {
|
|||||||
divisionsSerialized []byte
|
divisionsSerialized []byte
|
||||||
serviceSerialized []byte
|
serviceSerialized []byte
|
||||||
divisionsSplits map[string][]byte
|
divisionsSplits map[string][]byte
|
||||||
mustUseChecksum bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *serviceDescription) isValidToken(apiToken primitive.ObjectID) bool {
|
func (sh *serviceDescription) isValidToken(apiToken primitive.ObjectID) bool {
|
||||||
@ -148,7 +162,6 @@ func (sh *serviceDescription) readProfile(authtype string, id string, binfo stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(userinfo.token) == 0 {
|
if len(userinfo.token) == 0 {
|
||||||
return "", errors.New("refreshtoken token not found")
|
return "", errors.New("refreshtoken token not found")
|
||||||
}
|
}
|
||||||
@ -165,6 +178,13 @@ 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)
|
||||||
@ -173,14 +193,6 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
defaultDivNames[dn] = true
|
defaultDivNames[dn] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(div.Url_Deprecated) > 0 && len(div.Urls) == 0 {
|
|
||||||
div.Urls = bson.M{"warehouse": div.Url_Deprecated}
|
|
||||||
}
|
|
||||||
|
|
||||||
div.urlsSerialized, _ = json.Marshal(bson.M{
|
|
||||||
"service": div.Urls,
|
|
||||||
})
|
|
||||||
|
|
||||||
divsForUsers[dn] = &div.DivisionForUser
|
divsForUsers[dn] = &div.DivisionForUser
|
||||||
if len(div.State) == 0 {
|
if len(div.State) == 0 {
|
||||||
div.State = DivisionState_FullOpen
|
div.State = DivisionState_FullOpen
|
||||||
@ -239,32 +251,22 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
|||||||
defaultMarshaled, _ := json.Marshal(defaultsDivs)
|
defaultMarshaled, _ := json.Marshal(defaultsDivs)
|
||||||
sh.divisionsSplits["default"] = defaultMarshaled
|
sh.divisionsSplits["default"] = defaultMarshaled
|
||||||
|
|
||||||
sh.MaximumNumLinkAccount = config.MaximumNumLinkAccount
|
sh.MaximumNumLinkAccount = mg.maingateConfig.MaximumNumLinkAccount
|
||||||
sh.mongoClient = mg.mongoClient
|
sh.mongoClient = mg.mongoClient
|
||||||
sh.sessionProvider = mg.sessionProvider
|
sh.auths = mg.auths
|
||||||
sh.sessionTTL = time.Duration(config.SessionTTL * int64(time.Second))
|
sh.sessionTTL = time.Duration(mg.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
|
||||||
sh.getProviderInfo = mg.getProviderInfo
|
sh.getProviderInfo = mg.getProviderInfo
|
||||||
|
|
||||||
if globalApiToken, err := primitive.ObjectIDFromHex(config.GlobalMaingateToken); err == nil {
|
sh.wl = &mg.wl
|
||||||
if !globalApiToken.IsZero() {
|
sh.bl = &mg.bl
|
||||||
f := func() bool {
|
|
||||||
for _, t := range sh.ServerApiTokens {
|
|
||||||
if t == globalApiToken {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}()
|
|
||||||
if !f {
|
|
||||||
sh.ServerApiTokens = append(sh.ServerApiTokens, globalApiToken)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sh.serviceSerialized, _ = json.Marshal(sh)
|
sh.serviceSerialized, _ = json.Marshal(sh)
|
||||||
|
|
||||||
|
logger.Println("service is ready :", sh.ServiceCode, string(sh.serviceSerialized))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,35 +292,10 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
newType := queryvals.Get("ntype")
|
newType := queryvals.Get("ntype")
|
||||||
newId := queryvals.Get("nid")
|
newId := queryvals.Get("nid")
|
||||||
|
|
||||||
oldAuth, err := sh.sessionProvider.Query(sk)
|
oldAuth := sh.auths.Find(sk)
|
||||||
if err != nil {
|
if oldAuth == nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
// 잘못된 세션
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
logger.Println("link failed. session key is not valid :", sk)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
bfinfo, err := sh.getUserBrowserInfo(r)
|
|
||||||
if err != nil {
|
|
||||||
logger.ErrorWithCallStack(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
guestlink := (oldAuth.Platform == "guest")
|
|
||||||
if !guestlink {
|
|
||||||
_, err = sh.readProfile(oldType, oldId, bfinfo)
|
|
||||||
if err != nil {
|
|
||||||
logger.ErrorWithCallStack(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.Println("from guest acc to real acc link : ", oldId, bfinfo, newType, newId, bfinfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
oldType, oldId, err = sh.getProviderInfo(oldType, oldId)
|
|
||||||
if err != nil {
|
|
||||||
logger.ErrorWithCallStack(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -334,17 +311,42 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
// fmt.Println(oldAuth.Uid)
|
// fmt.Println(oldAuth.Uid)
|
||||||
// fmt.Println("=================")
|
// fmt.Println("=================")
|
||||||
|
|
||||||
//if oldAuth.Token != oldToken || oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
bfinfo, err := sh.getUserBrowserInfo(r)
|
||||||
if oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
if err != nil {
|
||||||
logger.Println("link failed. session key is not correct :", oldAuth, queryvals)
|
logger.Error("getUserBrowserInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//email, err := sh.readProfile(newType, newId, bfinfo)
|
guestlink := (len(oldType) == 0)
|
||||||
_, err = sh.readProfile(newType, newId, bfinfo)
|
if !guestlink {
|
||||||
|
_, err = sh.readProfile(oldType, oldId, bfinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("readProfile(old) failed :", err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Println("from guest acc to real acc link : ", oldId, bfinfo, newType, newId, bfinfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
oldType, oldId, err = sh.getProviderInfo(oldType, oldId)
|
||||||
|
if err != nil {
|
||||||
|
logger.Println("getProviderInfo failed :", err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//if oldAuth.Token != oldToken || oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
||||||
|
if oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
||||||
|
logger.Println("link failed. session key is not correct :", *oldAuth, queryvals)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
email, err := sh.readProfile(newType, newId, bfinfo)
|
||||||
|
if err != nil {
|
||||||
|
logger.Println("readProfile(new) failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -357,23 +359,11 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
newType, newId, err = sh.getProviderInfo(newType, newId)
|
newType, newId, err = sh.getProviderInfo(newType, newId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("getProviderInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := sh.mongoClient.FindOne(CollectionLink, bson.M{"platform": newType, "uid": newId}, options.FindOne())
|
|
||||||
if err != nil {
|
|
||||||
logger.ErrorWithCallStack(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if found != nil {
|
|
||||||
logger.Println("link failed. already have service account: ", r.URL.Query())
|
|
||||||
w.Write([]byte(`{"alreadylink":true}`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
createtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
createtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
||||||
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
||||||
"platform": newType,
|
"platform": newType,
|
||||||
@ -381,11 +371,11 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$setOnInsert": bson.M{
|
"$setOnInsert": bson.M{
|
||||||
"create": createtime,
|
"create": createtime,
|
||||||
//"email": email,
|
"email": email,
|
||||||
},
|
},
|
||||||
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"_id": 1}))
|
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"_id": 1}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("link failed. FindOneAndUpdate link err:", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -394,13 +384,13 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
"_id": link["_id"].(primitive.ObjectID),
|
"_id": link["_id"].(primitive.ObjectID),
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$setOnInsert": bson.M{
|
"$setOnInsert": bson.M{
|
||||||
"accid": oldAuth.Account,
|
"accid": oldAuth.Accid,
|
||||||
"create": createtime,
|
"create": createtime,
|
||||||
},
|
},
|
||||||
}, options.Update().SetUpsert(true))
|
}, options.Update().SetUpsert(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("link failed. Update ServiceName err :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,10 +439,11 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
sk := queryvals.Get("sk")
|
sk := queryvals.Get("sk")
|
||||||
targetType := queryvals.Get("ttype")
|
targetType := queryvals.Get("ttype")
|
||||||
|
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
authInfo := sh.auths.Find(sk)
|
||||||
if err != nil {
|
if authInfo == nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
// 잘못된 세션
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
logger.Println("linkinfo failed. session key is not valid :", sk)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +455,7 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
// fmt.Println(authInfo.Uid)
|
// fmt.Println(authInfo.Uid)
|
||||||
// fmt.Println("=================")
|
// fmt.Println("=================")
|
||||||
|
|
||||||
sType, sId, err = sh.getProviderInfo(sType, sId)
|
sType, sId, err := sh.getProviderInfo(sType, sId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Println("getProviderInfo failed :", err)
|
logger.Println("getProviderInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -472,19 +463,20 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if authInfo.Uid != sId || authInfo.Platform != sType {
|
if authInfo.Uid != sId || authInfo.Platform != sType {
|
||||||
logger.Println("unlink failed. session key is not correct :", authInfo, queryvals)
|
logger.Println("unlink failed. session key is not correct :", *authInfo, queryvals)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accDocs, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{
|
accDocs, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{
|
||||||
"accid": authInfo.Account,
|
"accid": authInfo.Accid,
|
||||||
}, options.Find().SetProjection(bson.M{
|
}, options.Find().SetProjection(bson.M{
|
||||||
"_id": 1,
|
"_id": 1,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("unlink failed, fail to count accounts :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(accDocs) <= 1 {
|
if len(accDocs) <= 1 {
|
||||||
@ -503,7 +495,7 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
"_id": bson.M{"$in": ids},
|
"_id": bson.M{"$in": ids},
|
||||||
}, options.FindOneAndDelete().SetProjection(bson.M{"_id": 1}))
|
}, options.FindOneAndDelete().SetProjection(bson.M{"_id": 1}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("unlink failed. FindOneAndDelete link err:", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -512,11 +504,10 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
"_id": link["_id"].(primitive.ObjectID),
|
"_id": link["_id"].(primitive.ObjectID),
|
||||||
}, options.FindOneAndDelete().SetProjection(bson.M{"_id": 1}))
|
}, options.FindOneAndDelete().SetProjection(bson.M{"_id": 1}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("unlink failed. Delete ServiceName err :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if preid == nil {
|
if preid == nil {
|
||||||
logger.Println("unlink failed. service account not found:", r.URL.Query())
|
logger.Println("unlink failed. service account not found:", r.URL.Query())
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -526,7 +517,7 @@ func (sh *serviceDescription) unlink(w http.ResponseWriter, r *http.Request) {
|
|||||||
logger.Println("unlink success :", r.URL.Query())
|
logger.Println("unlink success :", r.URL.Query())
|
||||||
}
|
}
|
||||||
|
|
||||||
// == 연결된 계정 정보(platform) 전달하는 API
|
// == 연결된 계정 정보(숫자) 전달하는 API
|
||||||
func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
||||||
defer func() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
@ -545,10 +536,11 @@ func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
sId := queryvals.Get("sid")
|
sId := queryvals.Get("sid")
|
||||||
sk := queryvals.Get("sk")
|
sk := queryvals.Get("sk")
|
||||||
|
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
authInfo := sh.auths.Find(sk)
|
||||||
if err != nil {
|
if authInfo == nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
// 잘못된 세션
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
logger.Println("linkinfo failed. session key is not valid :", sk)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,26 +552,28 @@ func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
// fmt.Println(authInfo.Uid)
|
// fmt.Println(authInfo.Uid)
|
||||||
// fmt.Println("=================")
|
// fmt.Println("=================")
|
||||||
|
|
||||||
sType, sId, err = sh.getProviderInfo(sType, sId)
|
sType, sId, err := sh.getProviderInfo(sType, sId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("getProviderInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//if oldAuth.Token != oldToken || oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
//if oldAuth.Token != oldToken || oldAuth.Uid != oldId || oldAuth.Platform != oldType {
|
||||||
if authInfo.Uid != sId || authInfo.Platform != sType {
|
if authInfo.Uid != sId || authInfo.Platform != sType {
|
||||||
logger.Println("linkinfo failed. session key is not correct :", authInfo, queryvals)
|
logger.Println("linkinfo failed. session key is not correct :", *authInfo, queryvals)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
platformName := "platform"
|
platformName := "platform"
|
||||||
accDocs, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{"accid": authInfo.Account}, options.Find().SetLimit(sh.MaximumNumLinkAccount).SetProjection(bson.M{
|
accDocs, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{
|
||||||
|
"accid": authInfo.Accid,
|
||||||
|
}, options.Find().SetLimit(sh.MaximumNumLinkAccount).SetProjection(bson.M{
|
||||||
"_id": 1,
|
"_id": 1,
|
||||||
}))
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("linkinfo failed. CountDocuments err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -595,7 +589,7 @@ func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
platformName: 1,
|
platformName: 1,
|
||||||
}))
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("linkinfo failed. FindAll returns err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -607,7 +601,7 @@ func (sh *serviceDescription) linkinfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
linkbytes, err := json.Marshal(linkstrs)
|
linkbytes, err := json.Marshal(linkstrs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("linkinfo failed. json marshal fail :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -631,22 +625,16 @@ func (sh *serviceDescription) emailinfo(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryvals := r.URL.Query()
|
queryvals := r.URL.Query()
|
||||||
reqauthtype := queryvals.Get("type")
|
sk := queryvals.Get("sk")
|
||||||
uid := queryvals.Get("id")
|
|
||||||
|
|
||||||
bfinfo, err := sh.getUserBrowserInfo(r)
|
authInfo := sh.auths.Find(sk)
|
||||||
if err != nil {
|
if authInfo == nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println(" session key is not valid :", sk)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
email, err := sh.readProfile(reqauthtype, uid, bfinfo)
|
email := authInfo.Email
|
||||||
if err != nil {
|
|
||||||
logger.ErrorWithCallStack(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(email, "__dummy_") && strings.HasSuffix(email, "temp__") {
|
if strings.HasPrefix(email, "__dummy_") && strings.HasSuffix(email, "temp__") {
|
||||||
email = ""
|
email = ""
|
||||||
@ -662,19 +650,7 @@ func (sh *serviceDescription) emailinfo(w http.ResponseWriter, r *http.Request)
|
|||||||
//logger.Println("Email :", email)
|
//logger.Println("Email :", email)
|
||||||
|
|
||||||
w.Write([]byte(fmt.Sprintf(`{"email":"%s"}`, email)))
|
w.Write([]byte(fmt.Sprintf(`{"email":"%s"}`, email)))
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *serviceDescription) authorize_dev(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if r.Method == "DELETE" {
|
|
||||||
sk := r.Header.Get("AS-X-SESSION")
|
|
||||||
if authinfo, err := sh.sessionProvider.Query(sk); err == nil {
|
|
||||||
sh.sessionProvider.RevokeAll(authinfo.Account)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
sh.authorize(w, r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request) {
|
func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -691,83 +667,74 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryvals := r.URL.Query()
|
queryvals := r.URL.Query()
|
||||||
reqauthtype := queryvals.Get("type")
|
authtype := queryvals.Get("type")
|
||||||
uid := queryvals.Get("id")
|
uid := queryvals.Get("id")
|
||||||
|
//accesstoken := queryvals.Get("token") //-- 이거 이제 받지마라
|
||||||
checksum := r.Header.Get("AS-X-CHECKSUM")
|
session := queryvals.Get("sk")
|
||||||
if len(checksum) > 0 || sh.mustUseChecksum {
|
|
||||||
nonce := queryvals.Get("nonce")
|
|
||||||
cookie := r.Header.Get("Cookie")
|
|
||||||
|
|
||||||
h := md5.New()
|
|
||||||
h.Write([]byte(cookie + nonce))
|
|
||||||
|
|
||||||
if checksum != hex.EncodeToString(h.Sum(nil)) {
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var email string
|
var email string
|
||||||
if !*noauth && (*authtype == "on" || *authtype == "both") {
|
|
||||||
if len(reqauthtype) > 0 {
|
if !*noauth {
|
||||||
|
if len(authtype) > 0 {
|
||||||
//email, err := sh.readProfile(authtype, uid, accesstoken)
|
//email, err := sh.readProfile(authtype, uid, accesstoken)
|
||||||
bfinfo, err := sh.getUserBrowserInfo(r)
|
bfinfo, err := sh.getUserBrowserInfo(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("getUserBrowserInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
email, err = sh.readProfile(reqauthtype, uid, bfinfo)
|
email, err = sh.readProfile(authtype, uid, bfinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("readProfile failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
newType, newId, err := sh.getProviderInfo(reqauthtype, uid)
|
newType, newId, err := sh.getProviderInfo(authtype, uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Println("getProviderInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if reqauthtype != newType || uid != newId {
|
if authtype != newType || uid != newId {
|
||||||
reqauthtype = newType
|
logger.Printf("auth success ( redirect ) : %s->%s, %s->%s, %s, %s", authtype, newType, uid, newId, email, session)
|
||||||
|
authtype = newType
|
||||||
uid = newId
|
uid = newId
|
||||||
}
|
}
|
||||||
} else if *authtype == "both" {
|
|
||||||
email = fmt.Sprintf("%s@guest.flag", uid)
|
|
||||||
} else {
|
} else {
|
||||||
// authtype이 없으면 입장 불가
|
email = fmt.Sprintf("%s@guest.flag", uid)
|
||||||
logger.Error("authorize failed. 'type' query parameter is missing")
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
email = fmt.Sprintf("%s@noauth.flag", uid)
|
email = fmt.Sprintf("%s@noauth.flag", uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if len(session) == 0 && len(email) > 0 {
|
||||||
|
if len(session) == 0 {
|
||||||
// platform + id -> account id
|
// platform + id -> account id
|
||||||
createtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
createtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
||||||
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
||||||
"platform": reqauthtype,
|
"platform": authtype,
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$setOnInsert": bson.M{
|
"$setOnInsert": bson.M{
|
||||||
"create": createtime,
|
"create": createtime,
|
||||||
//"email": email,
|
"email": email,
|
||||||
},
|
},
|
||||||
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"_id": 1, "_ts": 1}))
|
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{
|
||||||
|
"_id": 1,
|
||||||
|
"_ts": 1,
|
||||||
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("authorize failed :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
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{
|
||||||
@ -777,7 +744,7 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
},
|
},
|
||||||
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"accid": 1, "create": 1}))
|
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"accid": 1, "create": 1}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("authorize failed. Update sh.ServiceName err:", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -786,39 +753,45 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
oldcreate := account["create"].(primitive.DateTime)
|
oldcreate := account["create"].(primitive.DateTime)
|
||||||
newaccount := oldcreate == createtime
|
newaccount := oldcreate == createtime
|
||||||
|
|
||||||
var bi blockinfo
|
var bi *blockinfo
|
||||||
if err := sh.mongoClient.FindOneAs(CollectionBlock, bson.M{"accid": accid, "end": bson.M{"$gt": time.Now().UTC()}}, &bi); err == nil {
|
if sh.bl.contains(accid, &bi) {
|
||||||
// 블럭된 계정. 블락 정보를 알려준다.
|
// 블럭된 계정. 블락 정보를 알려준다.
|
||||||
w.Header().Add("MG-ACCOUNTBLOCK-START", strconv.FormatInt(bi.Start.Time().Unix(), 10))
|
w.Header().Add("MG-ACCOUNTBLOCK-START", strconv.FormatInt(bi.Start.Time().Unix(), 10))
|
||||||
w.Header().Add("MG-ACCOUNTBLOCK-END", strconv.FormatInt(bi.End.Time().Unix(), 10))
|
w.Header().Add("MG-ACCOUNTBLOCK-END", strconv.FormatInt(bi.End.Time().Unix(), 10))
|
||||||
|
w.Header().Add("MG-ACCOUNTBLOCK-REASON", bi.Reason)
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
alias := r.Header.Get("AS-X-ALIAS")
|
newsession := primitive.NewObjectID()
|
||||||
if len(alias) == 0 {
|
expired := primitive.NewDateTimeFromTime(time.Now().UTC().Add(sh.sessionTTL))
|
||||||
alias = email
|
newauth := gocommon.Authinfo{
|
||||||
|
Accid: accid,
|
||||||
|
ServiceCode: sh.ServiceCode,
|
||||||
|
Platform: authtype,
|
||||||
|
Uid: uid,
|
||||||
|
Email: email,
|
||||||
|
Sk: newsession,
|
||||||
|
Expired: expired,
|
||||||
|
//RefreshToken: queryvals.Get("rt"),
|
||||||
}
|
}
|
||||||
|
|
||||||
sk, err := sh.sessionProvider.New(&session.Authorization{
|
_, _, err = sh.mongoClient.UpsertOne(CollectionAuth, bson.M{"_id": newauth.Accid}, &newauth)
|
||||||
Account: accid,
|
|
||||||
Platform: reqauthtype,
|
|
||||||
Uid: uid,
|
|
||||||
Alias: alias,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("authorize failed :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Println("session created :", accid, authtype, uid, email, newsession)
|
||||||
|
|
||||||
output := map[string]any{
|
output := map[string]any{
|
||||||
"sk": sk,
|
"sk": newsession.Hex(),
|
||||||
"expirein": sh.sessionTTL.Seconds(),
|
"expirein": sh.sessionTTL.Seconds(),
|
||||||
"newAccount": newaccount,
|
"newAccount": newaccount,
|
||||||
"accid": accid.Hex(),
|
"accid": newauth.Accid.Hex(),
|
||||||
}
|
}
|
||||||
if len(reqauthtype) == 0 {
|
if *noauth {
|
||||||
output["noauth"] = true
|
output["noauth"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,8 +802,71 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
w.Header().Add("MG-ACCOUNT-DELETED", "TRUE")
|
w.Header().Add("MG-ACCOUNT-DELETED", "TRUE")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bt, _ := json.Marshal(output)
|
||||||
|
w.Write(bt)
|
||||||
|
} else if len(session) > 0 {
|
||||||
|
sessionobj, _ := primitive.ObjectIDFromHex(session)
|
||||||
|
if !sessionobj.IsZero() {
|
||||||
|
updated, _, err := sh.mongoClient.Update(CollectionAuth,
|
||||||
|
bson.M{
|
||||||
|
"sk": sessionobj,
|
||||||
|
},
|
||||||
|
bson.M{
|
||||||
|
"$currentDate": bson.M{
|
||||||
|
"_ts": bson.M{"$type": "date"},
|
||||||
|
},
|
||||||
|
}, options.Update().SetUpsert(false))
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("update auth collection failed :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(output)
|
if !updated {
|
||||||
|
// 세션이 없네?
|
||||||
|
logger.Println("authorize failed. session not exists in database :", session)
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output := map[string]any{
|
||||||
|
"sk": session,
|
||||||
|
"expirein": sh.sessionTTL.Seconds(),
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Println("session updated :", authtype, uid, session)
|
||||||
|
|
||||||
|
authInfo := sh.auths.Find(session)
|
||||||
|
if authInfo == nil {
|
||||||
|
// 잘못된 세션
|
||||||
|
logger.Println("authorize failed. fail to find authInfo :", session)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//혹시 삭제 된 계정 아닌지 확인해본다.
|
||||||
|
link, err := sh.mongoClient.FindOne(CollectionLink, bson.M{
|
||||||
|
"platform": authtype,
|
||||||
|
"uid": uid,
|
||||||
|
}, options.FindOne().SetProjection(bson.M{
|
||||||
|
"_ts": 1,
|
||||||
|
}))
|
||||||
|
if link["_ts"] != nil {
|
||||||
|
delts := link["_ts"].(primitive.DateTime)
|
||||||
|
if !delts.Time().IsZero() {
|
||||||
|
// 삭제된 계정. 삭제 되었다고 알려주자
|
||||||
|
w.Header().Add("MG-ACCOUNT-DELETED", "TRUE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bt, _ := json.Marshal(output)
|
||||||
|
w.Write(bt)
|
||||||
|
} else {
|
||||||
|
logger.Println("authorize failed. sk is not valid hex :", session)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Println("authorize failed. id empty :", queryvals)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *serviceDescription) findVersionSplit(version string) []byte {
|
func (sh *serviceDescription) findVersionSplit(version string) []byte {
|
||||||
@ -865,32 +901,35 @@ func (sh *serviceDescription) delacc(w http.ResponseWriter, r *http.Request) {
|
|||||||
sk := queryvals.Get("sk")
|
sk := queryvals.Get("sk")
|
||||||
cancel := queryvals.Has("cancel")
|
cancel := queryvals.Has("cancel")
|
||||||
|
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
authInfo := sh.auths.Find(sk)
|
||||||
if err != nil {
|
if authInfo == nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
// 잘못된 세션
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
logger.Println("delacc failed. session key is not valid :", sk)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
originAuthType := sType
|
originAuthType := sType
|
||||||
if !*devflag || len(sType) != 0 {
|
sType, sId, err := sh.getProviderInfo(sType, sId)
|
||||||
sType, sId, err = sh.getProviderInfo(sType, sId)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("delacc failed. getProviderInfo err :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if authInfo.Uid != sId || authInfo.Platform != sType {
|
if authInfo.Uid != sId || authInfo.Platform != sType {
|
||||||
logger.Println("delacc failed. session key is not correct :", authInfo, queryvals)
|
logger.Println("delacc failed. session key is not correct :", *authInfo, queryvals)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
linkidMap, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{"accid": authInfo.Account}, options.Find().SetProjection(bson.M{"_id": 1}))
|
linkidMap, err := sh.mongoClient.FindAll(CollectionAccount, bson.M{
|
||||||
|
"accid": authInfo.Accid,
|
||||||
|
}, options.Find().SetProjection(bson.M{
|
||||||
|
"_id": 1,
|
||||||
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("delacc failed. FindAll account err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -903,52 +942,42 @@ func (sh *serviceDescription) delacc(w http.ResponseWriter, r *http.Request) {
|
|||||||
delfilter := primitive.M{"_id": bson.M{"$in": linkidAry}}
|
delfilter := primitive.M{"_id": bson.M{"$in": linkidAry}}
|
||||||
var delop primitive.M
|
var delop primitive.M
|
||||||
if !cancel {
|
if !cancel {
|
||||||
curtime := time.Now().UTC()
|
curtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
||||||
if *devflag && len(sType) == 0 {
|
delop = primitive.M{
|
||||||
curtime = curtime.Add(time.Second * time.Duration(10-config.AccDelTTL))
|
"$set": primitive.M{"_ts": curtime},
|
||||||
}
|
}
|
||||||
delop = primitive.M{"$set": primitive.M{"_ts": primitive.NewDateTimeFromTime(curtime)}}
|
|
||||||
|
|
||||||
if originAuthType == AuthPlatformFirebaseAuth {
|
if originAuthType == AuthPlatformFirebaseAuth {
|
||||||
if sType == "guest" {
|
sh.mongoClient.Delete(CollectionFirebaseUserInfo, bson.M{
|
||||||
logger.Error("delacc failed. cannot delete a guest account.")
|
"firebaseuserid": sId,
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
})
|
||||||
return
|
|
||||||
}
|
|
||||||
sh.mongoClient.Delete(CollectionFirebaseUserInfo, bson.M{"firebaseuserid": sId})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delfilter["platform"] = sType
|
delfilter["platform"] = sType
|
||||||
targetLinkId, err := sh.mongoClient.FindAll(CollectionLink, delfilter, options.Find().SetProjection(bson.M{"_id": 1}))
|
targetLinkId, err := sh.mongoClient.FindAll(CollectionLink, delfilter, options.Find().SetProjection(bson.M{
|
||||||
|
"_id": 1,
|
||||||
|
}))
|
||||||
if len(targetLinkId) != 1 {
|
if len(targetLinkId) != 1 {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("delacc failed. FindAll link err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
delfilter = primitive.M{"_id": targetLinkId[0]["_id"].(primitive.ObjectID)}
|
delfilter = primitive.M{"_id": targetLinkId[0]["_id"].(primitive.ObjectID)}
|
||||||
delop = primitive.M{"$unset": primitive.M{"_ts": true}}
|
delop = primitive.M{
|
||||||
|
"$unset": primitive.M{"_ts": true},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updated, _, err := sh.mongoClient.Update(CollectionAccount, delfilter, delop, options.Update().SetUpsert(false))
|
updated, _, err := sh.mongoClient.Update(CollectionAccount, delfilter, delop, options.Update().SetUpsert(false))
|
||||||
if err != nil {
|
if !updated || err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("delacc failed. Update CollectionAccount timestamp err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !updated {
|
|
||||||
logger.Error("delacc failed. Update CollectionAccount timestamp. undated is false")
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updated, _, err = sh.mongoClient.Update(CollectionLink, delfilter, delop, options.Update().SetUpsert(false))
|
updated, _, err = sh.mongoClient.Update(CollectionLink, delfilter, delop, options.Update().SetUpsert(false))
|
||||||
if err != nil {
|
if !updated || err != nil {
|
||||||
logger.ErrorWithCallStack(err)
|
logger.Error("delacc failed. Update CollectionLink timestamp err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !updated {
|
|
||||||
logger.Error("delacc failed. Update CollectionLink timestamp. updated is false")
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -956,14 +985,6 @@ func (sh *serviceDescription) delacc(w http.ResponseWriter, r *http.Request) {
|
|||||||
logger.Println("delacc success :", linkidMap)
|
logger.Println("delacc success :", linkidMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *serviceDescription) serveHTTP_dev(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if strings.HasSuffix(r.URL.Path, "/auth") {
|
|
||||||
sh.authorize_dev(w, r)
|
|
||||||
} else {
|
|
||||||
sh.serveHTTP(w, r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request) {
|
func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
defer func() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
@ -1003,14 +1024,7 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
// TODO : 각 서버에 있는 자산? 캐릭터 정보를 보여줘야 하나. 뭘 보여줄지는 프로젝트에 문의
|
// TODO : 각 서버에 있는 자산? 캐릭터 정보를 보여줘야 하나. 뭘 보여줄지는 프로젝트에 문의
|
||||||
// 일단 서버 종류만 내려보내자
|
// 일단 서버 종류만 내려보내자
|
||||||
// 세션키가 있는지 확인
|
// 세션키가 있는지 확인
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
if _, ok := sh.auths.IsValid(sk, ""); !ok {
|
||||||
if err != nil {
|
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if authInfo.Account.IsZero() {
|
|
||||||
logger.Println("sessionkey is not valid :", sk)
|
logger.Println("sessionkey is not valid :", sk)
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@ -1031,14 +1045,7 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
// TODO : 각 서버에 있는 자산? 캐릭터 정보를 보여줘야 하나. 뭘 보여줄지는 프로젝트에 문의
|
// TODO : 각 서버에 있는 자산? 캐릭터 정보를 보여줘야 하나. 뭘 보여줄지는 프로젝트에 문의
|
||||||
// 일단 서버 종류만 내려보내자
|
// 일단 서버 종류만 내려보내자
|
||||||
// 세션키가 있는지 확인
|
// 세션키가 있는지 확인
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
if _, ok := sh.auths.IsValid(sk, ""); !ok {
|
||||||
if err != nil {
|
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if authInfo.Account.IsZero() {
|
|
||||||
logger.Println("sessionkey is not valid :", sk)
|
logger.Println("sessionkey is not valid :", sk)
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@ -1046,36 +1053,27 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
divname := queryvals.Get("div")
|
divname := queryvals.Get("div")
|
||||||
divname = strings.Trim(divname, `"`)
|
divname = strings.Trim(divname, `"`)
|
||||||
div, ok := sh.Divisions[divname]
|
div := sh.Divisions[divname]
|
||||||
if !ok {
|
|
||||||
div = sh.Divisions["default"]
|
|
||||||
}
|
|
||||||
|
|
||||||
var addrresp []byte
|
|
||||||
if div != nil {
|
if div != nil {
|
||||||
logger.Println("/addr :", divname, div.State)
|
|
||||||
|
|
||||||
switch div.State {
|
switch div.State {
|
||||||
case DivisionState_FullOpen:
|
case DivisionState_FullOpen:
|
||||||
addrresp = div.urlsSerialized
|
w.Write([]byte(fmt.Sprintf(`{"service":"%s"}`, div.Url)))
|
||||||
|
|
||||||
case DivisionState_RestrictedOpen:
|
case DivisionState_RestrictedOpen:
|
||||||
// 점검중이면 whitelist만 입장 가능
|
// 점검중이면 whitelist만 입장 가능
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
cell := sh.auths.QuerySession(sk, "")
|
||||||
if err != nil {
|
if cell == nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
logger.Println("sessionkey is not valid :", sk)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
wm := &whitelistmember{Email: cell.ToAuthinfo().Email, Platform: cell.ToAuthinfo().Platform}
|
||||||
wm := &whitelistmember{Alias: authInfo.Alias, Platform: authInfo.Platform}
|
if sh.wl.contains(wm.Key(), nil) {
|
||||||
doc, err := sh.mongoClient.FindOne(CollectionWhitelist, bson.M{"alias": wm.Key()})
|
|
||||||
if err == nil && doc != nil {
|
|
||||||
// qa 권한이면 입장 가능
|
// qa 권한이면 입장 가능
|
||||||
addrresp = div.urlsSerialized
|
w.Write([]byte(fmt.Sprintf(`{"service":"%s"}`, div.Url)))
|
||||||
} else if div.Maintenance != nil {
|
} else if div.Maintenance != nil {
|
||||||
// 권한이 없으므로 공지
|
// 권한이 없으므로 공지
|
||||||
addrresp = []byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link))
|
w.Write([]byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)))
|
||||||
} else {
|
} else {
|
||||||
logger.Println("div.Maintenance is nil :", divname)
|
logger.Println("div.Maintenance is nil :", divname)
|
||||||
}
|
}
|
||||||
@ -1083,18 +1081,17 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
case DivisionState_Maintenance:
|
case DivisionState_Maintenance:
|
||||||
// 점검중. 아무도 못들어감
|
// 점검중. 아무도 못들어감
|
||||||
if div.Maintenance != nil {
|
if div.Maintenance != nil {
|
||||||
logger.Println("/addr :", divname, div.State, *div.Maintenance)
|
w.Write([]byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link)))
|
||||||
addrresp = []byte(fmt.Sprintf(`{"notice":"%s"}`, div.Maintenance.link))
|
|
||||||
} else {
|
} else {
|
||||||
logger.Println("div.Maintenance is nil :", divname)
|
logger.Println("div.Maintenance is nil :", divname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Println("/addr resp :", string(addrresp))
|
|
||||||
w.Write(addrresp)
|
|
||||||
} else {
|
} else {
|
||||||
logger.Println("div is not found :", divname, sh.Divisions)
|
logger.Println("div is not found :", divname, sh.Divisions)
|
||||||
logger.Println("check maingate database 'service.divisions' :", config.Mongo)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Println("??? :", r.URL.Path)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package core
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -18,6 +19,14 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type authPipelineDocument struct {
|
||||||
|
OperationType string `bson:"operationType"`
|
||||||
|
DocumentKey struct {
|
||||||
|
Id primitive.ObjectID `bson:"_id"`
|
||||||
|
} `bson:"documentKey"`
|
||||||
|
Authinfo *gocommon.Authinfo `bson:"fullDocument"`
|
||||||
|
}
|
||||||
|
|
||||||
type servicePipelineDocument struct {
|
type servicePipelineDocument struct {
|
||||||
OperationType string `bson:"operationType"`
|
OperationType string `bson:"operationType"`
|
||||||
DocumentKey struct {
|
DocumentKey struct {
|
||||||
@ -34,7 +43,7 @@ type filePipelineDocument struct {
|
|||||||
File *FileDocumentDesc `bson:"fullDocument"`
|
File *FileDocumentDesc `bson:"fullDocument"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) {
|
func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux *http.ServeMux, prefix string) {
|
||||||
defer func() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
if s != nil {
|
if s != nil {
|
||||||
@ -119,7 +128,7 @@ func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux goco
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) {
|
func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux *http.ServeMux, prefix string) {
|
||||||
defer func() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
if s != nil {
|
if s != nil {
|
||||||
@ -213,3 +222,87 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func watchAuthCollection(parentctx context.Context, ac *gocommon.AuthCollection, mongoClient gocommon.MongoClient) {
|
||||||
|
defer func() {
|
||||||
|
s := recover()
|
||||||
|
if s != nil {
|
||||||
|
logger.Error(s)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
matchStage := bson.D{
|
||||||
|
{
|
||||||
|
Key: "$match", Value: bson.D{
|
||||||
|
{Key: "operationType", Value: bson.D{
|
||||||
|
{Key: "$in", Value: bson.A{
|
||||||
|
"delete",
|
||||||
|
"insert",
|
||||||
|
"update",
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
projectStage := bson.D{
|
||||||
|
{
|
||||||
|
Key: "$project", Value: bson.D{
|
||||||
|
{Key: "documentKey", Value: 1},
|
||||||
|
{Key: "operationType", Value: 1},
|
||||||
|
{Key: "fullDocument", Value: 1},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var stream *mongo.ChangeStream
|
||||||
|
var err error
|
||||||
|
var ctx context.Context
|
||||||
|
|
||||||
|
for {
|
||||||
|
if stream == nil {
|
||||||
|
stream, err = mongoClient.Watch(CollectionAuth, mongo.Pipeline{matchStage, projectStage})
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("watchAuthCollection watch failed :", err)
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ctx = context.TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
changed := stream.TryNext(ctx)
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
logger.Error("watchAuthCollection stream.TryNext failed. process should be restarted! :", ctx.Err().Error())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if changed {
|
||||||
|
var data authPipelineDocument
|
||||||
|
if err := stream.Decode(&data); err == nil {
|
||||||
|
ot := data.OperationType
|
||||||
|
switch ot {
|
||||||
|
case "insert":
|
||||||
|
ac.AddRaw(&mongoAuthCell{src: data.Authinfo})
|
||||||
|
case "update":
|
||||||
|
ac.AddRaw(&mongoAuthCell{src: data.Authinfo})
|
||||||
|
case "delete":
|
||||||
|
ac.RemoveByAccId(data.DocumentKey.Id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.Error("watchAuthCollection stream.Decode failed :", err)
|
||||||
|
}
|
||||||
|
} else if stream.Err() != nil || stream.ID() == 0 {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
logger.Println("watchAuthCollection is done")
|
||||||
|
stream.Close(ctx)
|
||||||
|
return
|
||||||
|
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
logger.Error("watchAuthCollection stream error :", stream.Err())
|
||||||
|
stream.Close(ctx)
|
||||||
|
stream = nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
64
go.mod
64
go.mod
@ -1,38 +1,34 @@
|
|||||||
module repositories.action2quare.com/ayo/maingate
|
module repositories.action2quare.com/ayo/maingate
|
||||||
|
|
||||||
go 1.22.1
|
go 1.18
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
firebase.google.com/go v3.13.0+incompatible
|
firebase.google.com/go v3.13.0+incompatible
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||||
go.mongodb.org/mongo-driver v1.11.7
|
go.mongodb.org/mongo-driver v1.11.7
|
||||||
google.golang.org/api v0.157.0
|
google.golang.org/api v0.128.0
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240205060841-c31f838ba8a9
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go v0.111.0 // indirect
|
cloud.google.com/go v0.110.2 // indirect
|
||||||
cloud.google.com/go/compute v1.23.3 // indirect
|
cloud.google.com/go/compute v1.20.1 // indirect
|
||||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||||
cloud.google.com/go/firestore v1.14.0 // indirect
|
cloud.google.com/go/firestore v1.10.0 // indirect
|
||||||
cloud.google.com/go/iam v1.1.5 // indirect
|
cloud.google.com/go/iam v1.1.1 // indirect
|
||||||
cloud.google.com/go/longrunning v0.5.4 // indirect
|
cloud.google.com/go/longrunning v0.5.1 // indirect
|
||||||
cloud.google.com/go/storage v1.30.1 // indirect
|
cloud.google.com/go/storage v1.30.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
|
||||||
github.com/go-logr/logr v1.3.0 // indirect
|
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/s2a-go v0.1.7 // indirect
|
github.com/google/go-cmp v0.5.9 // indirect
|
||||||
github.com/google/uuid v1.5.0 // indirect
|
github.com/google/s2a-go v0.1.4 // indirect
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
|
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
|
||||||
|
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
|
||||||
github.com/klauspost/compress v1.16.6 // indirect
|
github.com/klauspost/compress v1.16.6 // indirect
|
||||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||||
github.com/pires/go-proxyproto v0.7.0 // indirect
|
github.com/pires/go-proxyproto v0.7.0 // indirect
|
||||||
@ -42,22 +38,20 @@ require (
|
|||||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
|
golang.org/x/crypto v0.10.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
|
golang.org/x/net v0.11.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.21.0 // indirect
|
golang.org/x/oauth2 v0.9.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.21.0 // indirect
|
golang.org/x/sync v0.3.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.21.0 // indirect
|
golang.org/x/sys v0.9.0 // indirect
|
||||||
golang.org/x/crypto v0.18.0 // indirect
|
golang.org/x/text v0.10.0 // indirect
|
||||||
golang.org/x/net v0.20.0 // indirect
|
golang.org/x/time v0.3.0 // indirect
|
||||||
golang.org/x/oauth2 v0.16.0 // indirect
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||||
golang.org/x/sync v0.6.0 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
golang.org/x/sys v0.16.0 // indirect
|
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||||
google.golang.org/appengine v1.6.8 // indirect
|
google.golang.org/grpc v1.56.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
|
|
||||||
google.golang.org/grpc v1.60.1 // indirect
|
|
||||||
google.golang.org/protobuf v1.32.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace repositories.action2quare.com/ayo/maingate => ./
|
||||||
|
|||||||
158
go.sum
158
go.sum
@ -1,27 +1,34 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.111.0 h1:YHLKNupSD1KqjDbQ3+LVdQ81h/UJbJyZG203cEfnQgM=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.111.0/go.mod h1:0mibmpKP1TyOOFYQY5izo0LnT+ecvOQ0Sg3OdmMiNRU=
|
cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA=
|
||||||
cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk=
|
cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw=
|
||||||
cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI=
|
cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg=
|
||||||
|
cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
||||||
cloud.google.com/go/firestore v1.14.0 h1:8aLcKnMPoldYU3YHgu4t2exrKhLQkqaXAGqT0ljrFVw=
|
cloud.google.com/go/firestore v1.10.0 h1:FG5C49ukKKqyljY+XNRZGae1HZaiVe7aoqi2BipnBuM=
|
||||||
cloud.google.com/go/firestore v1.14.0/go.mod h1:96MVaHLsEhbvkBEdZgfN+AS/GIkco1LRpH9Xp9YZfzQ=
|
cloud.google.com/go/firestore v1.10.0/go.mod h1:eAeoQCV8F35Mcy4k8ZrQbcSYZOayIwoiU7ZJ6xzH1+o=
|
||||||
cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI=
|
cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y=
|
||||||
cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8=
|
cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU=
|
||||||
cloud.google.com/go/longrunning v0.5.4 h1:w8xEcbZodnA2BbW6sVirkkoC+1gP8wS57EUUgGS0GVg=
|
cloud.google.com/go/longrunning v0.5.1 h1:Fr7TXftcqTudoyRJa113hyaqlGdiBQkp0Gq7tErFDWI=
|
||||||
cloud.google.com/go/longrunning v0.5.4/go.mod h1:zqNVncI0BOP8ST6XQD1+VcvuShMmq7+xFSzOL++V0dI=
|
cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHSQl/fRUUQJYJc=
|
||||||
cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM=
|
cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM=
|
||||||
cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
|
cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
|
||||||
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
||||||
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -30,16 +37,11 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
|
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
|
||||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
@ -50,13 +52,16 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
|
|||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
@ -73,17 +78,19 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw=
|
github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw=
|
||||||
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
|
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
|
||||||
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
|
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
|
github.com/googleapis/enterprise-certificate-proxy v0.2.5 h1:UR4rDjcgpgEnqpIEvkiqTYKBCKLNmlge2eVjoZfySzM=
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
|
github.com/googleapis/enterprise-certificate-proxy v0.2.5/go.mod h1:RxW0N9901Cko1VOCW3SXCpWP+mlIEkk2tP7jnHy9a3w=
|
||||||
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
|
github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4=
|
||||||
github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
|
github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||||
github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk=
|
github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk=
|
||||||
github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||||
@ -105,14 +112,17 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
|
||||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||||
@ -131,24 +141,15 @@ go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJv
|
|||||||
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
|
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
|
||||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE=
|
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE=
|
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
|
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo=
|
|
||||||
go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc=
|
|
||||||
go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo=
|
|
||||||
go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4=
|
|
||||||
go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM=
|
|
||||||
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
|
|
||||||
go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc=
|
|
||||||
go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
|
||||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
@ -156,48 +157,55 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl
|
|||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
|
||||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
|
golang.org/x/oauth2 v0.9.0 h1:BPpt2kU7oMRq3kCHAA1tbSEshXRw1LpG2ztgDwrzuAs=
|
||||||
|
golang.org/x/oauth2 v0.9.0/go.mod h1:qYgFZaFiu6Wg24azG8bdV52QJXJGbZzIIsRCdVKzbLw=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
@ -207,29 +215,35 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
|||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
||||||
google.golang.org/api v0.157.0 h1:ORAeqmbrrozeyw5NjnMxh7peHO0UzV4wWYSwZeCUb20=
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
|
||||||
google.golang.org/api v0.157.0/go.mod h1:+z4v4ufbZ1WEpld6yMGHyggs+PmAHiaLNj5ytP3N01g=
|
google.golang.org/api v0.128.0 h1:RjPESny5CnQRn9V6siglged+DZCgfu9l6mO9dkX9VOg=
|
||||||
|
google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg=
|
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao=
|
||||||
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0=
|
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM=
|
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0=
|
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
|
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||||
|
google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE=
|
||||||
|
google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@ -241,16 +255,20 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
|
|||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86 h1:vP0mVST68cw14fI/af3Xp1ZQoYjkNGK4S0zji1BVfSI=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20230912075917-f9a146321cdb h1:Rdf6uhBIWunRLZ2LIT1hSovYXxZoOzx9mdSK5bjWpos=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86/go.mod h1:XA8+hQtUNh956T+kAbJKkUtMl5HUWj83knvdBvvPS5s=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20230912075917-f9a146321cdb/go.mod h1:rn6NA28Mej+qgLNx/Bu2wsdGyIycmacqlNP6gUXX2a0=
|
||||||
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240205060841-c31f838ba8a9 h1:5cQ60XjlI7k0qld0rIpd6gy7+a9csv3ijz1EVKTzsy8=
|
||||||
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240205060841-c31f838ba8a9/go.mod h1:rn6NA28Mej+qgLNx/Bu2wsdGyIycmacqlNP6gUXX2a0=
|
||||||
|
|||||||
15
main.go
15
main.go
@ -2,7 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"repositories.action2quare.com/ayo/gocommon"
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||||
@ -19,29 +21,26 @@ func main() {
|
|||||||
flagx.Parse()
|
flagx.Parse()
|
||||||
|
|
||||||
logger.Println("build revision =", revision)
|
logger.Println("build revision =", revision)
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
mg, err := core.New(ctx)
|
mg, err := core.New(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("core.New failed :", err)
|
logger.Error("core.New failed :", err)
|
||||||
return
|
panic(err)
|
||||||
}
|
}
|
||||||
defer mg.Destructor()
|
|
||||||
|
|
||||||
serveMux := http.NewServeMux()
|
serveMux := http.NewServeMux()
|
||||||
if err := mg.RegisterHandlers(ctx, serveMux, *prefix); err != nil {
|
if err := mg.RegisterHandlers(ctx, serveMux, *prefix); err != nil {
|
||||||
logger.Error("RegisterHandlers failed :", err)
|
logger.Error("RegisterHandlers failed :", err)
|
||||||
return
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
server := gocommon.NewHTTPServer(serveMux)
|
server := gocommon.NewHTTPServer(serveMux)
|
||||||
logger.Println("maingate is started")
|
logger.Println("maingate is started")
|
||||||
|
|
||||||
if err := server.Start(); err != nil {
|
if err := server.Start(); err != nil {
|
||||||
logger.Error("maingate is stopped with error :", err)
|
logger.Error("maingate is stopped with error :", err)
|
||||||
}
|
}
|
||||||
|
cancel()
|
||||||
logger.Println("maingate is terminated")
|
mg.Destructor()
|
||||||
}
|
}
|
||||||
|
|||||||
14
make_maingate_package.ps1
Normal file
14
make_maingate_package.ps1
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# $ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
|
$CurBranch = git branch --show-current
|
||||||
|
|
||||||
|
Remove-Item maingate.zip -Force -Recurse -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
$Env:GOOS="linux"
|
||||||
|
$Env:GOARCH="amd64"
|
||||||
|
go build -ldflags="-s -w" .
|
||||||
|
|
||||||
|
Compress-Archive -Path maingate -Update -DestinationPath maingate.zip
|
||||||
|
Compress-Archive -Path *-firebase-*.json -Update -DestinationPath maingate.zip
|
||||||
|
Compress-Archive -Path fba -Update -DestinationPath maingate.zip
|
||||||
|
Compress-Archive -Path template -Update -DestinationPath maingate.zip
|
||||||
Reference in New Issue
Block a user