Overview
Authorization in HERCULES SGI is based on:- Realm Roles: Assigned to users in Keycloak
- JWT Claims: Roles are embedded in access tokens
- Method Security: Spring Security annotations protect endpoints
- Custom Expressions: SGI-specific authorization logic
Role Naming Convention
Roles follow a hierarchical naming pattern:Components
- MODULE: The system module (CSP, ETI, PII, PRC, etc.)
- ENTITY: The resource or entity type
- PERMISSION: The action allowed (C, R, E, B, V, etc.)
Permission Types
| Code | Permission | Description |
|---|---|---|
C | Create | Create new resources |
R | Read | View resource details |
E | Edit | Modify existing resources |
B | Delete | Remove resources |
V | View | List and query resources |
INV | Investigator | Researcher-specific operations |
MOD | Moderator | Moderation capabilities |
EVAL | Evaluator | Evaluation permissions |
Core Modules and Roles
CSP Module (Research Projects)
The CSP module manages research projects, grants, and related entities.Project Management (CSP-PRO)
Project Management (CSP-PRO)
Available Roles:
CSP-PRO-C: Create projectsCSP-PRO-E: Edit projectsCSP-PRO-B: Delete projectsCSP-PRO-V: View project listCSP-PRO-R: Read project detailsCSP-PRO-INV-VR: Investigator view rightsCSP-PRO-MOD-V: Moderator view
Grants (CSP-SOL)
Grants (CSP-SOL)
Available Roles:
CSP-SOL-C: Create grant applicationsCSP-SOL-E: Edit applicationsCSP-SOL-B: Delete applicationsCSP-SOL-V: View applicationsCSP-SOL-R: Read application detailsCSP-SOL-INV-C: Investigator createCSP-SOL-INV-V: Investigator viewCSP-SOL-ETI-V: Ethics committee view
Contracts (CSP-CON)
Contracts (CSP-CON)
Available Roles:
CSP-CON-C: Create contractsCSP-CON-E: Edit contractsCSP-CON-B: Delete contractsCSP-CON-V: View contractsCSP-CON-R: Read contract detailsCSP-CON-INV-V: Investigator view
Budget Execution (CSP-EJEC)
Budget Execution (CSP-EJEC)
Available Roles:
CSP-EJEC-E: Edit budget executionCSP-EJEC-V: View execution statusCSP-EJEC-INV-VR: Investigator view rights
ETI Module (Ethics Committee)
Manages ethics evaluations and committee operations. Key Roles:ETI-ACT-C: Create ethics committee minutesETI-ACT-E: Edit minutesETI-ACT-V: View minutesETI-EVC-EVAL: Evaluate ethics applicationsETI-EVC-EVALR: Reviewer evaluationETI-EVC-V: View evaluationsETI-MEM-V: View committee membersETI-MEM-INV-CR: Investigator create rightsETI-PEV-INV-VR: Investigator evaluation viewETI-CNV-C: Create meetingsETI-CNV-V: View meetings
PII Module (Intellectual Property)
Manages patents, trademarks, and intellectual property. Key Roles:PII-INV-C: Create inventionsPII-INV-E: Edit inventionsPII-INV-V: View inventionsPII-INV-R: Read invention detailsPII-TPR-C: Create patentsPII-TPR-E: Edit patentsPII-TPR-V: View patentsPII-VPR-C: Create patent valuationsPII-VPR-E: Edit valuationsPII-SEA-E: Edit sectorsPII-TRE-C: Create contracts
PRC Module (Production)
Manages production validation and reporting. Key Roles:PRC-VAL-E: Edit validationsPRC-VAL-V: View validationsPRC-VAL-INV-ER: Investigator edit rightsPRC-CON-C: Create configurationsPRC-CON-E: Edit configurationsPRC-CON-V: View configurationsPRC-INF-G: Generate reportsPRC-INF-INV-GR: Investigator generate reports
Additional Modules
- EER: Business entities registry
- REL: Relationships management
- ESB: External services integration
- ADM-CNF: System administration and configuration
Making Authorized API Requests
All API requests must include a valid access token in the Authorization header:Bearer token obtained from Keycloak authenticationFormat:
Bearer {access_token}Example Requests
Service-to-Service Authentication
For microservice communication, services use their client credentials to obtain tokens with appropriate scopes.Available Scopes
| Scope | Description |
|---|---|
sgi-cnf | Configuration service access |
sgi-com | Communication service access |
sgi-eti | Ethics committee service access |
sgi-sgp | Personnel management access |
sgi-tp | Third parties service access |
Service Authentication Example
Permission Checking Patterns
Spring Security Annotations
HERCULES SGI uses Spring Security’s method security:Custom Security Expressions
TheSgiMethodSecurityExpressionRoot provides custom authorization methods:
hasAnyAuthorityForAnyUO(): Check if user has role for any organizational unithasAuthorityForUO(): Check role for specific organizational unit
Protected Endpoint Patterns
Standard CRUD Operations
| HTTP Method | Endpoint Pattern | Required Role Pattern |
|---|---|---|
| GET | /recursos | {MODULE}-{ENTITY}-V |
| GET | /recursos/{id} | {MODULE}-{ENTITY}-R |
| POST | /recursos | {MODULE}-{ENTITY}-C |
| PUT | /recursos/{id} | {MODULE}-{ENTITY}-E |
| DELETE | /recursos/{id} | {MODULE}-{ENTITY}-B |
Investigator-Specific Endpoints
Endpoints with/investigador/ prefix require investigator roles:
Handling Authorization Errors
401 Unauthorized
Returned when no valid token is provided or token is expired:403 Forbidden
Returned when token is valid but user lacks required permissions:Role Assignment
Roles are assigned to users in the Keycloak Admin Console:Testing Authorization
To test endpoint authorization:Complete Role Reference
The SGI realm contains over 400 role definitions across all modules. Key role patterns include:- CSP-*: Research projects and grants (167 roles)
- ETI-*: Ethics committee operations (47 roles)
- PII-*: Intellectual property (29 roles)
- PRC-*: Production and validation (12 roles)
- EER-*: Business entities (4 roles)
- REL-*: Relationships (3 roles)
- ESB-*: External services (4 roles)
- ADM-CNF-E: System administration
Next Steps
Authentication
Learn how to obtain access tokens
API Endpoints
Explore available API endpoints