abapGit/docs/ref-authorizations.md
Lars Hvam fff8f1b237
new URL, updates (#3936)
* Update build.yml

* docs, update urls

* code, update links
2020-09-24 09:42:52 +02:00

1.4 KiB

title category order
Authorizations reference 50

You can block actions from users using Authorizations.

You need to create a class named ZCL_ABAPGIT_AUTH_EXIT implementing interface ZIF_ABAPGIT_AUTH, and put inside include zabapgit_authorizations_exit ¹ .

Note: If you are using the abapGit development version, do not create the class in the abapGit package.

The interface ZIF_ABAPGIT_AUTH has a constant with all the possible authorizations. Such as:

  • uninstall
  • transport_to_branch
  • update_local_checksum

Example

Suppose you want to limit the uninstalling of packages to a user named Admin. Your code could look like:

*&---------------------------------------------------------------------*
*&  Include  zabapgit_authorizations_exit
*&---------------------------------------------------------------------*
CLASS zcl_abapgit_auth_exit DEFINITION
 CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES zif_abapgit_auth.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_abapgit_auth_exit IMPLEMENTATION.
  METHOD zif_abapgit_auth~is_allowed.
    IF iv_authorization = zif_abapgit_auth~gc_authorization-uninstall.
      IF sy-uname = 'ADMIN'.
        rv_allowed = abap_true.
      ELSE.
        rv_allowed = abap_false.
      ENDIF.
    ENDIF.
  ENDMETHOD.
ENDCLASS.