abapGit/docs/ref-authorizations.md
Eduardo Ferrari Copat 273f0682bc Docs: Authorizations (#2186)
* Insert initial line before bothsequence and action

* Package names validations

validate if package has more than 30 characters name and if root packages does not contain a package with the same name as his.

* Docs: authorizations

* typo + grammar

* newline at EOF
2018-12-06 08:12:58 +01:00

51 lines
1.4 KiB
Markdown

---
title: Authorizations
category: reference
order: 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` [¹](https://github.com/larshp/abapGit/blob/52758028a7b08101e9c76d1cdab8639d776d3d2b/src/zabapgit.prog.abap#L35 "Link to source code include location") .
**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:
```abap
*&---------------------------------------------------------------------*
*& 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.
```