noauth 플래그 처리
This commit is contained in:
@ -80,6 +80,7 @@ func init() {
|
|||||||
CollectionAuth = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionAuth)))
|
CollectionAuth = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionAuth)))
|
||||||
CollectionWhitelist = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionWhitelist)))
|
CollectionWhitelist = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionWhitelist)))
|
||||||
CollectionService = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionService)))
|
CollectionService = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionService)))
|
||||||
|
CollectionAccount = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionAccount)))
|
||||||
CollectionBlock = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionBlock)))
|
CollectionBlock = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionBlock)))
|
||||||
CollectionPlatformLoginToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionPlatformLoginToken)))
|
CollectionPlatformLoginToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionPlatformLoginToken)))
|
||||||
CollectionUserToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionUserToken)))
|
CollectionUserToken = common.CollectionName(fmt.Sprintf("%s-%s", hostname, string(CollectionUserToken)))
|
||||||
@ -448,8 +449,26 @@ func whitelistKey(email string) string {
|
|||||||
|
|
||||||
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error {
|
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error {
|
||||||
var allServices []*serviceDescription
|
var allServices []*serviceDescription
|
||||||
logger.Println(CollectionService)
|
|
||||||
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
if *flag.Noauth {
|
||||||
|
host, _ := os.Hostname()
|
||||||
|
empty := serviceDescription{
|
||||||
|
ServiceDescriptionSummary: ServiceDescriptionSummary{
|
||||||
|
ServiceCode: "000000000000",
|
||||||
|
},
|
||||||
|
Divisions: map[string]*Division{
|
||||||
|
host: {
|
||||||
|
DivisionForUser: DivisionForUser{
|
||||||
|
Priority: 0,
|
||||||
|
State: DivisionState_FullOpen,
|
||||||
|
},
|
||||||
|
Url: fmt.Sprintf("http://%s/warehouse", host),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
empty.prepare(mg)
|
||||||
|
allServices = append(allServices, &empty)
|
||||||
|
} else if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
common "repositories.action2quare.com/ayo/gocommon"
|
common "repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
|
"repositories.action2quare.com/ayo/maingate/flag"
|
||||||
|
|
||||||
"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"
|
||||||
@ -425,7 +426,9 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
uid := queryvals.Get("id")
|
uid := queryvals.Get("id")
|
||||||
//accesstoken := queryvals.Get("token") //-- 이거 이제 받지마라
|
//accesstoken := queryvals.Get("token") //-- 이거 이제 받지마라
|
||||||
session := queryvals.Get("sk")
|
session := queryvals.Get("sk")
|
||||||
|
var email string
|
||||||
|
|
||||||
|
if !*flag.Noauth {
|
||||||
//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 {
|
||||||
@ -434,7 +437,7 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
email, err := sh.readProfile(authtype, uid, bfinfo)
|
email, err = sh.readProfile(authtype, uid, bfinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("readProfile failed :", err)
|
logger.Error("readProfile failed :", err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -454,6 +457,9 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
uid = newId
|
uid = newId
|
||||||
logger.Println("auth success ( redirect ) :", authtype, uid, email, session)
|
logger.Println("auth success ( redirect ) :", authtype, uid, email, session)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
email = fmt.Sprintf("%s@noauth.flag", uid)
|
||||||
|
}
|
||||||
|
|
||||||
//if len(session) == 0 && len(email) > 0 {
|
//if len(session) == 0 && len(email) > 0 {
|
||||||
if len(session) == 0 {
|
if len(session) == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user