Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter only None values from records and some more #137

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@ jobs:
- '3.11'
- '3.12'

services:
ldap:
image: osixia/openldap:latest
ports:
- 389:389
env:
LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/misc/schema"
LDAP_DOMAIN: services.sram.tld
LDAP_ADMIN_USERNAME: admin
LDAP_ADMIN_PASSWORD: secret
LDAP_CONFIG_PASSWORD: config
LDAP_BASE_DN: dc=services,dc=sram,dc=tld
LDAP_TLS: true

steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
- name: Checkout
uses: actions/checkout@v4

- name: Start LDAP container
run: ./run-ldapci.sh

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libsasl2-dev libldap2-dev ldap-utils
Expand All @@ -60,11 +50,12 @@ jobs:
run: >
sleep 5;
ldapwhoami -H ${LDAP_URL} -D ${LDAP_BIND_DN} -w ${LDAP_ADMIN_PASSWORD};
ldapwhoami -H ${LDAP_URL} -D cn=admin,cn=config -w ${LDAP_CONFIG_PASSWORD};
for f in access eduPerson voPerson groupOfMembers config;
do
ldapadd -H ${LDAP_URL}
-D cn=admin,cn=config
-w ${LDAP_CONFIG_PASSWORD}
ldapadd -H ${LDAP_URL} \
-D cn=admin,cn=config \
-w ${LDAP_CONFIG_PASSWORD} \
-f etc/ldif/$f.ldif;
done;
env:
Expand Down Expand Up @@ -95,5 +86,14 @@ jobs:
LDAP_URL: ldap://localhost:389
LDAP_BASE_DN: dc=services,dc=sram,dc=tld

# Setup tmate session
- name: Setup tmate session
env:
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG}}
if: ${{ failure() && env.ACTIONS_STEP_DEBUG == 'true' }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
timeout-minutes: 60


36 changes: 10 additions & 26 deletions misc/schema/sramPerson.ldif
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
# Internet X.500 Schema for Ldappc
# Includes the sczGroup ObjectClass schema
# Includes the sramPerson ObjectClass schema
#
# An auxiliary object class, "sczGroup," is a convenient container
# for an extensible set of attributes concerning group memberships.
# An auxiliary object class, "sramPerson," is a convenient container
# for an extensible set of attributes concerning sram persons.
# At this time, the only attribute specified as belonging to the
# object class is "sczMember."
#
# It is specifically configured to support the memberOf overlay.
#
# object class is "sramInactiveDays".
#
dn: cn=sramPerson,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: sramPerson
olcAttributeTypes: ( 1.3.6.1.4.1.1076.20.100.20.2.1 NAME 'sramLastActivityDate'
DESC 'Date when this entity was last active'
EQUALITY generalizedTimeMatch
ORDERING generalizedTimeOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24
)
olcAttributeTypes: ( 1.3.6.1.4.1.1076.20.100.20.2.2 NAME 'sramAUPacceptedURI'
DESC 'URI of accepted AUP'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
)
olcAttributeTypes: ( 1.3.6.1.4.1.1076.20.100.20.2.3 NAME 'sramAUPacceptedDate'
DESC 'Date when the AUP was accepted'
EQUALITY generalizedTimeMatch
ORDERING generalizedTimeOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24
olcAttributeTypes: ( 1.3.6.1.4.1.1076.20.100.20.2.1 NAME 'sramInactiveDays'
DESC 'Number of days this entity was inactive'
EQUALITY IntegerMatch
ORDERING IntegerOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
)
olcObjectClasses: ( 1.3.6.1.4.1.1076.20.100.20.1.1 NAME 'sramPerson'
AUXILIARY
MAY (
sramLastActivityDate $
sramAUPacceptedURI $
sramAUPacceptedDate
sramInactiveDays
)
)
2 changes: 1 addition & 1 deletion plsc_ordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def res(days, interval):

# clean up the lists, such that we return empty lists if no attribute is present, rather than [None]
for key, val in record.items():
record[key] = list(filter(None, record[key]))
record[key] = list(filter(lambda n: n is not None, val))

rdn = f"uid={username}"

Expand Down
14 changes: 14 additions & 0 deletions run-ldapci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
docker rm ldap || true
docker run -d \
-e "LDAP_SEED_INTERNAL_SCHEMA_PATH=/opt/misc/schema" \
-e "LDAP_DOMAIN=services.sram.tld" \
-e "LDAP_ADMIN_USERNAME=admin" \
-e "LDAP_ADMIN_PASSWORD=secret" \
-e "LDAP_CONFIG_PASSWORD=config" \
-e "LDAP_BASE_DN=dc=services,dc=sram,dc=tld" \
-e "LDAP_TLS=true" \
-v "./misc/schema:/opt/misc/schema" \
-p 389:389 \
--name ldap \
osixia/openldap:latest
Loading