Security Entities¶
This section covers the 3 entities related to users, roles, and access control. Authentication is managed through Keycloak, while the ORM defines the authorization model.
User¶
System users synchronized with Keycloak.
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | BigInteger | PK, Auto-increment | Unique identifier |
| keycloak_ext_id | String(255) | NOT NULL | External Keycloak user ID |
| role_id | Integer | FK -> role.id, NOT NULL | Assigned role |
| enable | Boolean | Default: true | Soft delete flag |
| register | DateTime(tz) | NOT NULL | Creation timestamp |
| updated | DateTime(tz) | NOT NULL | Last update timestamp |
Relationships: Role (parent), UserAccess (children)
Role¶
User role definitions with application context.
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | Integer | PK, Auto-increment | Unique identifier |
| name | String(255) | NOT NULL | Role name |
| app | Enum(Apps) | NOT NULL | Application: aclimate_admin, aclimate_frontend |
| enable | Boolean | Default: true | Soft delete flag |
| register | DateTime(tz) | NOT NULL | Creation timestamp |
| updated | DateTime(tz) | NOT NULL | Last update timestamp |
Relationships: User (children), UserAccess (children)
UserAccess¶
Granular permissions per user, country, role, and module. Uses a composite primary key.
| Column | Type | Constraints | Description |
|---|---|---|---|
| user_id | Integer | PK, FK -> users.id | User |
| country_id | Integer | PK, FK -> mng_country.id | Country |
| role_id | Integer | PK, FK -> role.id | Role |
| module | Enum(Modules) | PK, NOT NULL | Module: GEOGRAPHIC, CLIMATE_DATA, CROP_DATA, etc. |
| create | Boolean | Default: false | Create permission |
| read | Boolean | Default: false | Read permission |
| update | Boolean | Default: false | Update permission |
| delete | Boolean | Default: false | Delete permission |
Relationships: User (parent), Role (parent), MngCountry (parent)
Module Values¶
| Module | Description |
|---|---|
| GEOGRAPHIC | Geographic data (countries, admin divisions) |
| CLIMATE_DATA | Climate data access |
| CROP_DATA | Crop data access |
| INDICATORS_DATA | Indicators data access |
| STRESS_DATA | Stress data access |
| PHENOLOGICAL_STAGE | Phenological stage data |
| USER_MANAGEMENT | User and role administration |
| CONFIGURATION | System configuration |