agentleFS
logalitechlogalitech/abap-skills/skills/authorization-iam/SKILL.md

authorization-iam

Skill0 starsChanged 3 months agoMITView on GitHub

Modelo de autorizaciones en ABAP/RAP: objetos de autorización, DCL, control global vs de instancia y roles. Úsala cuando el usuario diseñe autorizaciones, DCL, control de acceso por registro, o el método get_instance_authorizations en RAP.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No confíes solo en la UI para ocultar botones: las features controlan visibilidad, pero la seguridad real la dan autorización y DCL en el …

    line 85

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Authorization & IAM

Guía para diseñar autorizaciones en ABAP y RAP: objetos de autorización clásicos, control de acceso a datos con DCL, y control global vs de instancia en objetos de negocio RAP.

Cuándo y cómo usarla

  1. Identifica el objetivo: restringir qué operaciones puede hacer un usuario (global) o sobre qué registros concretos (instancia), o filtrar los datos que ve una CDS.
  2. Sitúa el contexto: distingue tres planos: autorización clásica (PFCG + objetos S_*), control de acceso a datos (DCL sobre CDS) y control de comportamiento (BDEF en RAP).
  3. Aplica el modelo por capas: DCL para filtrar lectura, BDEF para controlar operaciones, y objetos de autorización como base común.

Los tres planos de autorización

  • Objetos de autorización (PFCG): la base clásica. Un objeto (por ejemplo S_TRVL) tiene campos (sociedad, actividad) que se comprueban con AUTHORITY-CHECK o implícitamente.
  • DCL (Data Control Language): restringe los datos que devuelve una CDS. Filtra la lectura a nivel de fila según las autorizaciones PFCG.
  • BDEF (comportamiento RAP): controla qué operaciones (create/update/delete/acciones) puede ejecutar un usuario, global o por instancia.

DCL: filtrar datos por fila

Una CDS con @AccessControl.authorizationCheck: #CHECK exige un rol DCL. El rol se asigna implícitamente a todos los usuarios (mapping role) y filtra según sus autorizaciones PFCG.

@MappingRole: true
define role ZR_Travel_Auth {
  grant select on ZR_Travel
    where ( CompanyCode ) = aspect pfcg_auth( S_TRVL, BUKRS, ACTVT = '03' );
}

Notas: el control implícito solo actúa al acceder directamente a la vista con Open SQL o una consulta SADL. Si la CDS se usa como fuente de otra sin rol, no hay filtrado; planifica el DCL en las vistas por las que se accede realmente. Valores de la anotación: #CHECK (exige rol), #NOT_REQUIRED (igual sin warning), #NOT_ALLOWED (sin control).

Control global vs de instancia en RAP

En el behavior definition se declara el tipo de control de autorización:

managed implementation in class zbp_r_travel unique;
strict ( 2 );
define behavior for ZR_Travel alias Travel
persistent table ztravel
lock master
authorization master ( global, instance )   // ambos niveles
{
  create;
  update ( authorization : update );
  delete;

  action ( authorization : instance ) confirmTravel result [1] $self;
}
  • Global: aplica a toda la entidad. Si el usuario carece de la autorización global, no puede ejecutar la operación en ningún registro (por ejemplo, bloquear delete a un grupo de usuarios).
  • Instancia: se evalúa registro a registro según su contenido (sociedad, centro). El usuario puede operar sobre unos registros y no sobre otros.

Implementar las autorizaciones en el behavior pool

Declarar authorization ( global, instance ) genera métodos a implementar. En instancia, get_instance_authorizations decide, registro a registro, qué operaciones se permiten devolviendo constantes de if_abap_behv.

METHOD get_instance_authorizations.
  READ ENTITIES OF ZR_Travel IN LOCAL MODE
    ENTITY Travel
    FIELDS ( CompanyCode ) WITH CORRESPONDING #( keys )
    RESULT DATA(travels).

  result = VALUE #( FOR t IN travels
                    ( %tky                 = t-%tky
                      %update              = COND #( WHEN is_allowed( t-CompanyCode )
                                                     THEN if_abap_behv=>auth-allowed
                                                     ELSE if_abap_behv=>auth-unauthorized )
                      %action-confirmTravel = COND #( WHEN is_allowed( t-CompanyCode )
                                                     THEN if_abap_behv=>auth-allowed
                                                     ELSE if_abap_behv=>auth-unauthorized ) ) ).
ENDMETHOD.

Para el control global, el método correspondiente (get_global_authorizations) decide sin mirar registros concretos, típicamente con un AUTHORITY-CHECK sobre el objeto de autorización.

Buenas prácticas y errores comunes

  • No confíes solo en la UI para ocultar botones: las features controlan visibilidad, pero la seguridad real la dan autorización y DCL en el backend.
  • Combina las capas: DCL filtra lo que se ve, BDEF controla lo que se puede hacer. Una sin la otra deja huecos.
  • Ten en cuenta que DCL solo filtra en accesos directos: envuelve en una CDS con rol los accesos que deban quedar protegidos.
  • Reutiliza objetos de autorización estándar (S_*) cuando encajen, en lugar de inventar unos nuevos que nadie mantiene.
  • Prueba la autorización con usuarios de distinto perfil: un fallo de instancia solo se ve con datos de varias sociedades/centros.

Referencias

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.