go-duck-cli 1.1.24 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/multitenancy.js +2 -2
- package/generators/security.js +15 -1
- package/package.json +1 -1
|
@@ -173,9 +173,9 @@ func TenantMiddleware(db *gorm.DB, cfg *config.Config) gin.HandlerFunc {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if len(requestedTenants) > 0 {
|
|
176
|
-
db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE role_name IN ? AND tenant_id IN ?", lowerRoles, requestedTenants).Scan(&mappings)
|
|
176
|
+
db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ? AND tenant_id IN ?", lowerRoles, requestedTenants).Scan(&mappings)
|
|
177
177
|
} else {
|
|
178
|
-
db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE role_name IN ?", lowerRoles).Scan(&mappings)
|
|
178
|
+
db.Raw("SELECT role_name, db_name, is_primary FROM tenant_roles WHERE LOWER(role_name) IN ?", lowerRoles).Scan(&mappings)
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
if len(mappings) == 0 {
|
package/generators/security.js
CHANGED
|
@@ -174,9 +174,23 @@ func JWTMiddleware() gin.HandlerFunc {
|
|
|
174
174
|
if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
|
175
175
|
c.Set("KeycloakID", claims["sub"])
|
|
176
176
|
c.Set("UserEmail", claims["email"])
|
|
177
|
+
|
|
178
|
+
var allRoles []interface{}
|
|
177
179
|
if ra, ok := claims["realm_access"].(map[string]interface{}); ok {
|
|
178
|
-
|
|
180
|
+
if rList, ok := ra["roles"].([]interface{}); ok {
|
|
181
|
+
allRoles = append(allRoles, rList...)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if resAcc, ok := claims["resource_access"].(map[string]interface{}); ok {
|
|
185
|
+
for _, clientObj := range resAcc {
|
|
186
|
+
if clientMap, ok := clientObj.(map[string]interface{}); ok {
|
|
187
|
+
if rList, ok := clientMap["roles"].([]interface{}); ok {
|
|
188
|
+
allRoles = append(allRoles, rList...)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
179
192
|
}
|
|
193
|
+
c.Set("UserRoles", allRoles)
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
c.Next()
|