feat/sync-setting:

+ moved infra/sync-cfg to infra/sync-consumer-cfg
+ adjut anything related to old infra/sync
+ infra/sync is now have new setting for the sync
This commit is contained in:
2025-11-28 09:16:38 +07:00
parent 8360da06c8
commit b09c9f183c
29 changed files with 187 additions and 39 deletions
@@ -13,6 +13,8 @@ import (
mf "simrs-vx/internal/domain/main-entities/user-fes"
pa "simrs-vx/internal/lib/auth"
s "simrs-vx/internal/use-case/main-use-case/authentication"
esga "simrs-vx/internal/domain/sync-entities/authentication"
)
func Login(w http.ResponseWriter, r *http.Request) {
@@ -67,6 +69,23 @@ func Logout(w http.ResponseWriter, r *http.Request) {
func GuardMW(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check if it's from sync
credential := esga.CredentialDto{}
credential.Source = r.Header.Get("X-Sync-Source")
credential.SecretKey = r.Header.Get("X-Sync-SecretKey")
credential.UserName = r.Header.Get("X-Sync-UserName")
if credential.Source != "" || credential.SecretKey != "" || credential.UserName != "" {
ctx := context.WithValue(r.Context(), esga.SyncKey{}, credential)
next.ServeHTTP(w, r.WithContext(ctx))
// TO DO:
// 1 Get user info manually (not by using token), based on credential.UserName
// 2 To cover the point 1, Adjust /use-case/main-use-case/authentication to have the function
// 3 Any DTO that is used in the sync, add flag Sync (tru/false), set it true if it is from sync
return
}
// Normal flow goes here
accessDetail, err := s.ExtractToken(r, s.AccessToken)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
@@ -63,7 +63,7 @@ import (
gs "simrs-vx/internal/infra/gorm-setting"
minio "simrs-vx/internal/infra/minio"
ssdb "simrs-vx/internal/infra/ss-db"
simgossync "simrs-vx/internal/infra/sync-cfg"
sync "simrs-vx/internal/infra/sync-consumer-cfg"
/******************** pkg ********************/
cmw "simrs-vx/pkg/cors-manager-mw"
@@ -135,7 +135,7 @@ func SetRoutes() http.Handler {
a.RegisterExtCall(mh.I.SetClient)
a.RegisterExtCall(ibpjs.SetConfig)
a.RegisterExtCall(validation.RegisterValidation)
a.RegisterExtCall(simgossync.SetConfig)
a.RegisterExtCall(sync.SetConfig)
a.RegisterExtCall(docscfg.ParseCfg)
r := http.NewServeMux()