[오승석] email 저장 제거
- CollectionLink에 email 저장 안함 - whitelist key 변경: Email -> Alias
This commit is contained in:
@ -306,9 +306,12 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
|||||||
return logger.ErrorWithCallStack(err)
|
return logger.ErrorWithCallStack(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)
|
||||||
|
// }
|
||||||
|
if err = mg.mongoClient.DropIndex(CollectionLink, "emailplatform"); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return logger.ErrorWithCallStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,18 +30,14 @@ type blockinfo struct {
|
|||||||
|
|
||||||
type whitelistmember struct {
|
type whitelistmember struct {
|
||||||
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
Id primitive.ObjectID `bson:"_id" json:"_id"`
|
||||||
Email string `bson:"email" json:"email"`
|
Alias string `bson:"alias" json:"alias"`
|
||||||
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 {
|
||||||
if strings.HasPrefix(wh.Email, "*@") {
|
return wh.Alias
|
||||||
// 도메인 전체 허용
|
|
||||||
return wh.Email[2:]
|
|
||||||
}
|
|
||||||
return wh.Email
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wh *whitelistmember) Expired() bool {
|
func (wh *whitelistmember) Expired() bool {
|
||||||
@ -349,7 +345,8 @@ func (sh *serviceDescription) link(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
email, err := sh.readProfile(newType, newId, bfinfo)
|
//email, err := sh.readProfile(newType, newId, bfinfo)
|
||||||
|
_, err = sh.readProfile(newType, newId, bfinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("readProfile(new) failed :", err)
|
logger.Error("readProfile(new) failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -388,7 +385,7 @@ 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 {
|
||||||
@ -638,16 +635,22 @@ func (sh *serviceDescription) emailinfo(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryvals := r.URL.Query()
|
queryvals := r.URL.Query()
|
||||||
sk := queryvals.Get("sk")
|
reqauthtype := queryvals.Get("type")
|
||||||
|
uid := queryvals.Get("id")
|
||||||
|
|
||||||
authInfo, err := sh.sessionProvider.Query(sk)
|
bfinfo, err := sh.getUserBrowserInfo(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Println("sessionProvider.Query return err :", err)
|
logger.Error("getUserBrowserInfo failed :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
email := authInfo.Email
|
email, err := sh.readProfile(reqauthtype, uid, bfinfo)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("readProfile(new) failed :", 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 = ""
|
||||||
@ -663,7 +666,6 @@ 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) {
|
func (sh *serviceDescription) authorize_dev(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -789,7 +791,7 @@ func (sh *serviceDescription) authorize(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, "_ts": 1}))
|
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"_id": 1, "_ts": 1}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -826,11 +828,16 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alias := r.Header.Get("AS-X-ALIAS")
|
||||||
|
if len(alias) == 0 {
|
||||||
|
alias = email
|
||||||
|
}
|
||||||
|
|
||||||
sk, err = sh.sessionProvider.New(&session.Authorization{
|
sk, err = sh.sessionProvider.New(&session.Authorization{
|
||||||
Account: accid,
|
Account: accid,
|
||||||
Platform: reqauthtype,
|
Platform: reqauthtype,
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
Email: email,
|
Alias: alias,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("authorize failed. sessionProvider.New err:", err)
|
logger.Error("authorize failed. sessionProvider.New err:", err)
|
||||||
@ -1080,7 +1087,7 @@ func (sh *serviceDescription) serveHTTP(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
wm := &whitelistmember{Email: authInfo.Email, Platform: authInfo.Platform}
|
wm := &whitelistmember{Alias: authInfo.Alias, Platform: authInfo.Platform}
|
||||||
if _, ok := sh.wl.get(wm.Key()); ok {
|
if _, ok := sh.wl.get(wm.Key()); ok {
|
||||||
// qa 권한이면 입장 가능
|
// qa 권한이면 입장 가능
|
||||||
addrresp = div.urlsSerialized
|
addrresp = div.urlsSerialized
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ require (
|
|||||||
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.157.0
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240731015107-899bae335ee1
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -252,5 +252,5 @@ 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-20240731015107-899bae335ee1 h1:F69QHr4Qyr/z8tKw+gAHurGiiClwFoE+Xdmh3tZca9I=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86 h1:vP0mVST68cw14fI/af3Xp1ZQoYjkNGK4S0zji1BVfSI=
|
||||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20240731015107-899bae335ee1/go.mod h1:XA8+hQtUNh956T+kAbJKkUtMl5HUWj83knvdBvvPS5s=
|
repositories.action2quare.com/ayo/gocommon v0.0.0-20240806115838-ca5632031c86/go.mod h1:XA8+hQtUNh956T+kAbJKkUtMl5HUWj83knvdBvvPS5s=
|
||||||
|
|||||||
Reference in New Issue
Block a user