Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
xkureck committed Jun 8, 2022
2 parents a02ce39 + 5518477 commit fff95f6
Show file tree
Hide file tree
Showing 16 changed files with 468 additions and 145 deletions.
4 changes: 2 additions & 2 deletions gen/ad_admin_group_mu_ucn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';

local $::SERVICE_NAME = "ad_admin_group_mu_ucn";
local $::PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";

sub addMemberToGroup;
sub processWorkplaces;
Expand All @@ -23,7 +23,7 @@ my $DIRECTORY = perunServicesInit::getDirectory;
my $fileName = "$DIRECTORY/$::SERVICE_NAME".".ldif";

#Get hierarchical data without expired members
my $data = perunServicesInit::getHashedDataWithGroups(1);
my $data = perunServicesInit::getHashedDataWithGroups;
my $DEBUG = 0;

#Constants
Expand Down
4 changes: 2 additions & 2 deletions gen/ad_admin_user_mu_ucn
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use Encode;

local $::SERVICE_NAME = "ad_admin_user_mu_ucn";
local $::PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
my $fileName = "$DIRECTORY/$::SERVICE_NAME".".ldif";

my $data = perunServicesInit::getHashedHierarchicalData(1);
my $data = perunServicesInit::getHashedHierarchicalData;

#Constants
our $A_F_DOMAIN; *A_F_DOMAIN = \'urn:perun:facility:attribute-def:def:adDomain';
Expand Down
4 changes: 2 additions & 2 deletions gen/ad_group_mu_ucn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';

local $::SERVICE_NAME = "ad_group_mu_ucn";
local $::PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.4";
my $SCRIPT_VERSION = "3.0.5";

sub addMemberToGroup;
sub processWorkplaces;
Expand All @@ -26,7 +26,7 @@ my $fileName = "$DIRECTORY/$::SERVICE_NAME".".ldif";
my $baseDnFileName = "$DIRECTORY/baseDN";

# Get hierarchical data without expired members
my $data = perunServicesInit::getHashedDataWithGroups(1);
my $data = perunServicesInit::getHashedDataWithGroups;
my $DEBUG = 0;

#Constants
Expand Down
4 changes: 2 additions & 2 deletions gen/ad_user_mu_ucn
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use utf8;

local $::SERVICE_NAME = "ad_user_mu_ucn";
local $::PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";
my $SCRIPT_VERSION = "3.0.2";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
my $fileName = "$DIRECTORY/$::SERVICE_NAME".".ldif";
my $baseDnFileName = "$DIRECTORY/baseDN";

my $data = perunServicesInit::getHashedHierarchicalData(1);
my $data = perunServicesInit::getHashedHierarchicalData;

#Constants
our $A_F_BASE_DN; *A_F_BASE_DN = \'urn:perun:facility:attribute-def:def:adBaseDN';
Expand Down
17 changes: 10 additions & 7 deletions gen/arcgis_licenses_mu
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use JSON::XS;
use utf8;

our $SERVICE_NAME = "arcgis_licenses_mu";
our $PROTOCOL_VERSION = "3.0.0";
our $PROTOCOL_VERSION = "3.0.1";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
my $data = perunServicesInit::getHashedDataWithGroups(1);
my $data = perunServicesInit::getHashedDataWithGroups;

#Constants
our $A_USER_FIRST_NAME; *A_USER_FIRST_NAME = \'urn:perun:user:attribute-def:core:firstName';
Expand All @@ -24,7 +24,7 @@ our $A_RESOURCE_ARCGIS_AFFILIATION; *A_RESOURCE_ARCGIS_AFFILIATION = \'urn:perun

#Headers
my $firstNameHeader = "firstName";
my $lastNameHeader = "lastName";
my $lastNameHeader = "lastName";
my $loginHeader = "UCO";
my $rolesHeader = "roles";
my $affiliationHeader = "isActive";
Expand All @@ -37,16 +37,16 @@ my $usersWithRoles = {};
my $facilityId = $data->getFacilityId;

foreach my $resourceId ( $data->getResourceIds() ) {

my $roleOnResource = $data->getResourceAttributeValue( attrName => $A_RESOURCE_ARCGIS_ROLE, resource => $resourceId );
my $isResourceActiveForAffiliation = $data->getResourceAttributeValue( attrName => $A_RESOURCE_ARCGIS_AFFILIATION, resource => $resourceId );

#process all members on resource
#process all members on resource
foreach my $memberId ($data->getMemberIdsForResource( resource => $resourceId )) {
#skip not VALID members in VO
my $statusInVo = $data->getMemberAttributeValue( attrName => $A_MEMBER_STATUS, member => $memberId );
if( $statusInVo ne $statusValid ) { next; }

my $UCO = $data->getUserFacilityAttributeValue( attrName => $A_USER_LOGIN, member => $memberId, facility => $facilityId );

#if user not exists, create record for him first
Expand Down Expand Up @@ -87,11 +87,14 @@ for my $key (keys %{$usersWithRoles}) {
push @data, $userRecord;
}

# order all entries by UCO
@data = sort { $a->{$loginHeader} <=> $b->{$loginHeader} } @data;

#print json to the file
my $file = "$DIRECTORY/$::SERVICE_NAME.json";
open FILE,">$file" or die "Cannot open $file: $! \n";
binmode(FILE);
print FILE JSON::XS->new->utf8->pretty->encode(\@data);
print FILE JSON::XS->new->utf8->pretty->canonical->encode(\@data);
close (FILE) or die "Cannot close $file: $! \n";

perunServicesInit::finalize;
14 changes: 11 additions & 3 deletions gen/insight_mu
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use POSIX qw(strftime);

our $SERVICE_NAME = "insight_mu";
our $PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.2";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
# get only valid members
my $data = perunServicesInit::getHashedDataWithGroups(1);
my $data = perunServicesInit::getHashedDataWithGroups;

# CONSTANTS
our $A_USER_ID; *A_USER_ID = \'urn:perun:user:attribute-def:core:id';
Expand Down Expand Up @@ -80,7 +80,7 @@ foreach my $resourceId ($data->getResourceIds()) {
};
$memberDataById->{$uco} = $person;
}
my @membersList = keys %members;
my @membersList = sort { $a <=> $b } keys %members;
# decide whether group or workplace depending on defined VAZPR attribute
unless ( defined $groupVAZPR ) {
my $group = {
Expand Down Expand Up @@ -117,6 +117,14 @@ my @groupValues = values(%$groupDataById);
my @workplaceValues = values(%$workplaceDataById);
my @personValues = values(%$memberDataById);

# sort persons by UCO
@personValues = sort { $a->{'UCO'} <=> $b->{'UCO'} } @personValues;
# sort groups by externalObjectId = Group ID
@groupValues = sort { $a->{'ExternalObjectID'} <=> $b->{'ExternalObjectID'} } @groupValues;
# sort workplaces by externalObjectId = Group ID
@workplaceValues = sort { $a->{'ExternalObjectID'} <=> $b->{'ExternalObjectID'} } @workplaceValues;


# get data in desired format
my $groupData = {
data => {Contact => [{Group => [{PerunGroup => \@groupValues}]}]}
Expand Down
4 changes: 2 additions & 2 deletions gen/netbox
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use Data::Dumper;

our $SERVICE_NAME = "netbox";
our $PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";

my $file_name_users = "netbox_users";
my $file_name_groups = "netbox_groups";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
my $data = perunServicesInit::getHashedHierarchicalData(1);
my $data = perunServicesInit::getHashedHierarchicalData;

#Constants
our $A_RESOURCE_GROUP_NAME; *A_RESOURCE_GROUP_NAME = \'urn:perun:resource:attribute-def:def:netboxGroupName';
Expand Down
53 changes: 34 additions & 19 deletions gen/o365_mu
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ sub saveUsersToFile;
sub saveGroupsToFile;

our $SERVICE_NAME = "o365_mu";
our $PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";
our $PROTOCOL_VERSION = "3.1.0";
my $SCRIPT_VERSION = "3.1.1";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand All @@ -39,6 +39,19 @@ our $A_UF_O365_STORE_AND_FORWARD; *A_UF_O365_STORE_AND_FORWARD =
our $A_UF_O365_LICENCE; *A_UF_O365_LICENCE = \'urn:perun:user_facility:attribute-def:def:o365Licence';
our $A_R_IS_FOR_O365_GROUP; *A_R_IS_FOR_O365_GROUP = \'urn:perun:resource:attribute-def:def:isForO365Group';
our $A_F_ID; *A_F_ID = \'urn:perun:facility:attribute-def:core:id';

our $UPN_TEXT = "UPN";
our $MAIL_FORWARD_TEXT = "mailForward";
our $ARCHIVE_TEXT = "archive";
our $STORE_AND_FORWARD_TEXT = "storeAndForward";
our $EMAIL_ADDRESSES = "emailAddresses";

###------------------------------------------------------------------------------
### RESOURCE MAILBOXES CONFIGURATION
### WARNING: These variables are for purpose of resource mail boxes configuration
### and we are not using them at this moment! We still want to preserve
### this for continuing a work on service in the future.
###------------------------------------------------------------------------------
our $A_R_O365_RES_NAME; *A_R_O365_RES_NAME = \'urn:perun:resource:attribute-def:def:o365ResourceName';
our $A_R_O365_RES_ALIAS; *A_R_O365_RES_ALIAS = \'urn:perun:resource:attribute-def:def:o365ResourceAlias';
our $A_R_O365_RES_EMAIL_ADDRESES; *A_R_O365_RES_EMAIL_ADDRESES = \'urn:perun:resource:attribute-def:def:o365ResourceEmailAddresses';
Expand Down Expand Up @@ -66,7 +79,6 @@ our $A_GR_O365_RES_BOOK_IN_POLICY; *A_GR_O365_RES_BOOK_IN_POLICY =
our $A_GR_O365_RES_REQUEST_IN_POLICY; *A_GR_O365_RES_REQUEST_IN_POLICY = \'urn:perun:group_resource:attribute-def:def:o365ResourceRequestInPolicy';
our $A_GR_O365_RES_REQUEST_OUT_OF_POLICY; *A_GR_O365_RES_REQUEST_OUT_OF_POLICY = \'urn:perun:group_resource:attribute-def:def:o365ResourceRequestOutOfPolicy';
our $A_GR_O365_RES_DELEGATES; *A_GR_O365_RES_DELEGATES = \'urn:perun:group_resource:attribute-def:def:o365ResourceDelegates';

our $RES_NAME_TEXT = "RES_NAME";
our $RES_ALIAS_TEXT = "RES_ALIAS";
our $RES_EMAIL_ADDRESES_TEXT = "RES_EMAIL_ADDRESES";
Expand Down Expand Up @@ -94,11 +106,12 @@ our $RES_DELEGATES_TEXT = "RES_DELEGATES";
our $RES_BOOK_IN_POLICY_TEXT = "RES_BOOK_IN_POLICY";
our $RES_REQUEST_IN_POLICY_TEXT = "RES_REQUEST_IN_POLICY";
our $RES_REQUEST_OUT_OF_POLICY_TEXT = "RES_REQUEST_OUT_OF_POLICY";
our $UPN_TEXT = "UPN";
our $MAIL_FORWARD_TEXT = "mailForward";
our $ARCHIVE_TEXT = "archive";
our $STORE_AND_FORWARD_TEXT = "storeAndForward";
our $EMAIL_ADDRESSES = "emailAddresses";

our $resourceMails = {};
my $resourceMailsFileName = "$DIRECTORY/$::SERVICE_NAME-resource-mails";
###------------------------------------------------------------------------------
### END of RESOURCE MAILBOXES CONFIGURATION
###------------------------------------------------------------------------------

#Default forwarding domain for MU
our $DEFAULT_FORWARDING_DOMAIN = '@mo.muni.cz';
Expand All @@ -109,7 +122,6 @@ our $DEFAULT_FORWARDING_DOMAIN = '@mo.muni.cz';

our $users = {};
our $groups = {};
our $resourceMails = {};

#-------------------------------------------------------------------------
# PROCESSING FACILITY
Expand All @@ -135,12 +147,12 @@ foreach my $resourceId ( $data->getResourceIds() ) {

my $usersFileName = "$DIRECTORY/$::SERVICE_NAME-users";
my $groupsFileName = "$DIRECTORY/$::SERVICE_NAME-groups";
my $resourceMailsFileName = "$DIRECTORY/$::SERVICE_NAME-resource-mails";
my $facilityIdFileName = "$DIRECTORY/$::SERVICE_NAME-facilityId";

saveUsersToFile $usersFileName, $users;
saveGroupsToFile $groupsFileName, $groups;
saveResourceMailsToFile $resourceMailsFileName, $resourceMails;
###we don't want to process resource mailboxes until further change
#saveResourceMailsToFile $resourceMailsFileName, $resourceMails;
saveFacilityIdToFile $facilityIdFileName, $facilityId;

#-------------------------------------------------------------------------
Expand All @@ -164,20 +176,21 @@ sub processResource {

#define attributes for processing o365 groups and o365 resource maling lists
my $isForO365Group = $data->getResourceAttributeValue( resource => $resourceId, attrName => $A_R_IS_FOR_O365_GROUP );
my $resName = $data->getResourceAttributeValue( resource => $resourceId, attrName => $A_R_O365_RES_NAME );
#my $resName = $data->getResourceAttributeValue( resource => $resourceId, attrName => $A_R_O365_RES_NAME );

#process all members from resource (users data)
foreach my $memberId ($data->getMemberIdsForResource( resource => $resourceId )) {
processResourceMember $memberId;
}

### Skip of processing resource mails
#if resource mail name exists, process it as resource mail (resource-mails data)
if($resName) {
#prevent duplicity in resource name
if($resourceMails->{$resName}) { die "There is a duplicity of two Resources with the same resourceMailName: $resName\n"; }

processResourceMail $resourceId;
}
#if($resName) {
# #prevent duplicity in resource name
# if($resourceMails->{$resName}) { die "There is a duplicity of two Resources with the same resourceMailName: $resName\n"; }
#
# processResourceMail $resourceId;
#}

#if resource is set as o365 resource, process it with all it's groups (groups data)
if($isForO365Group) {
Expand Down Expand Up @@ -301,7 +314,9 @@ sub processResourceMember {
} else {
warn "Can't find emails for user with UCO: $UCO \n";
}
my $emailsString = join(',', sort @emailsArray);
#do not use sorting because of cache in send script (cache does not have sorted emails and such records would need to be updated even if there is no really change)
#my $emailsString = join(',', sort @emailsArray);
my $emailsString = join(',', @emailsArray);

unless($users->{$UCO}) {
$users->{$UCO}->{$UPN_TEXT} = $UCO . "@" . $domainName;
Expand Down
58 changes: 58 additions & 0 deletions gen/o365_mu_users_export
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/perl

use strict;
use warnings;
use perunServicesInit;
use perunServicesUtils;
use Data::Dumper;
use utf8;

local $::SERVICE_NAME = "o365_mu_users_export";
local $::PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.0";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
my $data = perunServicesInit::getHashedHierarchicalData;

#Constants
our $A_UF_LOGIN; *A_UF_LOGIN = \'urn:perun:user_facility:attribute-def:virt:login';
our $A_UF_O365_STATE; *A_UF_O365_STATE = \'urn:perun:user_facility:attribute-def:def:o365InternalUserState';
our $A_UF_DISABLE_O365_MAIL_FORWARD; *A_UF_DISABLE_O365_MAIL_FORWARD = \'urn:perun:user_facility:attribute-def:def:disableO365MailForward';
our $A_UF_O365_STORE_AND_FORWARD; *A_UF_O365_STORE_AND_FORWARD = \'urn:perun:user_facility:attribute-def:def:o365MailStoreAndForward';

my $validLogins = {};

#RULES:
#1] any user who has UCO
#2] status of user in o365 is not 0
#3] disableMailForward == true
#OR
#3] disableMailForward == false AND mailStoreAndForward == true
foreach my $memberId ( $data->getMemberIdsForFacility() ) {
my $uco = $data->getUserFacilityAttributeValue( member => $memberId, attrName => $A_UF_LOGIN );
#skip all users without UCO
next unless $uco;
my $o365Status = $data->getUserFacilityAttributeValue( member => $memberId, attrName => $A_UF_O365_STATE );
#skip all users with 0 or empty value in status attribute (everything except 0 is OK here)
next unless $o365Status;
my $disableMailForward = $data->getUserFacilityAttributeValue( member => $memberId, attrName => $A_UF_DISABLE_O365_MAIL_FORWARD );
my $storeAndForward = $data->getUserFacilityAttributeValue( member => $memberId, attrName => $A_UF_O365_STORE_AND_FORWARD );
unless( $disableMailForward ) {
#skip users with set forward without storing a copy
next unless $storeAndForward;
}
#if all rules are met, add uco to the list
$validLogins->{$uco} = $uco;
}

my $fileName = "$DIRECTORY/$::SERVICE_NAME";
open FILE,">$fileName" or die "Cannot open $fileName: $! \n";
binmode FILE, ":utf8";

foreach my $uco (sort keys %{$validLogins}) {
print FILE $uco . "\n";
}

close (FILE);
perunServicesInit::finalize;
Loading

0 comments on commit fff95f6

Please sign in to comment.