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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user