Revision f8f519ac
Amélioration des vérifications faites avant l'appel aux plugins dans le cas où l'utilisateur appartient au groupe 'managers'.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@6484 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/root.py | ||
---|---|---|
644 | 644 |
if plugin_name not in plugins: |
645 | 645 |
raise HTTPNotFound(_("No such plugin '%s'") % plugin_name) |
646 | 646 |
|
647 |
# Récupération de la liste des évènements corrélés |
|
648 |
events = DBSession.query(CorrEvent.idcorrevent) |
|
649 |
|
|
650 |
# Filtrage des évènements en fonction des permissions de |
|
651 |
# l'utilisateur (s'il n'appartient pas au groupe 'managers') |
|
647 | 652 |
is_manager = in_group('managers').is_met(request.environ) |
648 | 653 |
if not is_manager: |
649 | 654 |
|
650 |
# Récupération du nom de l'utilisateur |
|
651 | 655 |
user = get_current_user() |
652 | 656 |
|
653 |
# Vérification des permissions de l'utilisateur |
|
654 |
events = DBSession.query( |
|
655 |
CorrEvent.idcorrevent |
|
656 |
).join( |
|
657 |
events = events.join( |
|
657 | 658 |
(Event, Event.idevent == CorrEvent.idcause), |
658 | 659 |
).outerjoin( |
659 | 660 |
(LowLevelService, LowLevelService.idservice == Event.idsupitem), |
... | ... | |
667 | 668 |
) |
668 | 669 |
), |
669 | 670 |
).join( |
670 |
(GroupHierarchy, GroupHierarchy.idchild == SUPITEM_GROUP_TABLE.c.idgroup), |
|
671 |
(GroupHierarchy, |
|
672 |
GroupHierarchy.idchild == SUPITEM_GROUP_TABLE.c.idgroup), |
|
671 | 673 |
).join( |
672 |
(DataPermission, DataPermission.idgroup == GroupHierarchy.idparent), |
|
674 |
(DataPermission, |
|
675 |
DataPermission.idgroup == GroupHierarchy.idparent), |
|
673 | 676 |
).join( |
674 |
(USER_GROUP_TABLE, USER_GROUP_TABLE.c.idgroup == DataPermission.idusergroup), |
|
675 |
).filter(USER_GROUP_TABLE.c.username == user.user_name |
|
676 |
).filter(CorrEvent.idcorrevent == idcorrevent |
|
677 |
).count() |
|
677 |
(USER_GROUP_TABLE, |
|
678 |
USER_GROUP_TABLE.c.idgroup == DataPermission.idusergroup), |
|
679 |
).filter(USER_GROUP_TABLE.c.username == user.user_name) |
|
680 |
|
|
681 |
# Filtrage des évènements en fonction |
|
682 |
# de l'identifiant passé en paramètre |
|
683 |
events = events.filter(CorrEvent.idcorrevent == idcorrevent).count() |
|
678 | 684 |
|
679 |
# Pas d'événement ou permission refusée. On ne distingue pas
|
|
680 |
# les 2 cas afin d'éviter la divulgation d'informations.
|
|
681 |
if events == 0:
|
|
682 |
raise HTTPNotFound(_('No such incident or insufficient '
|
|
683 |
'permissions'))
|
|
685 |
# Pas d'événement ou permission refusée. On ne distingue pas |
|
686 |
# les 2 cas afin d'éviter la divulgation d'informations. |
|
687 |
if events == 0: |
|
688 |
raise HTTPNotFound(_('No such incident or insufficient ' |
|
689 |
'permissions')) |
|
684 | 690 |
|
691 |
# L'évènement existe bien, et l'utilisateur dispose |
|
692 |
# des permissions appropriées. On fait alors appel au |
|
693 |
# plugin pour récupérer les informations à retourner. |
|
685 | 694 |
return plugins[plugin_name].get_json_data(idcorrevent, *arg, **krgv) |
686 | 695 |
|
687 | 696 |
@validate(validators={ |
Also available in: Unified diff