Skip to content

Commit 590ed26

Browse files
committed
Enable again and configure LDAP correctly
1 parent 363f52c commit 590ed26

File tree

4 files changed

+62
-49
lines changed

4 files changed

+62
-49
lines changed

conf/local.py.j2

+32-37
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,42 @@ DATABASES = {
2929
'USER': '{{ db_user }}',
3030
'PASSWORD': '{{ db_pwd }}',
3131
'HOST': '127.0.0.1',
32-
'PORT': '5432',
32+
'PORT': '5432',
3333
},
3434
}
3535

3636
FEEDS = (('ffdn', 'http://www.ffdn.org/fr/rss.xml', 3),)
3737

3838

3939

40-
# # Tous acces
41-
# # parametrer SSO en protect_uris
42-
# # OU
43-
# # Pas d'acces
44-
# # hook
45-
# # parametrer SSO en protect_uris
46-
# import ldap
47-
# from django_auth_ldap.config import LDAPSearch, PosixGroupType
48-
# AUTHENTICATION_BACKENDS = (
49-
# 'django_auth_ldap.backend.LDAPBackend',
50-
# 'django.contrib.auth.backends.ModelBackend',
51-
# )
52-
# AUTH_LDAP_SERVER_URI = "ldap://localhost:389"
53-
# AUTH_LDAP_USER_SEARCH = LDAPSearch("uid={{ admin }},ou=users,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
54-
# AUTH_LDAP_USER_ATTR_MAP = {
55-
# "username": "uid",
56-
# "first_name": "givenName",
57-
# "last_name": "sn",
58-
# "email": "mail",
59-
# }
60-
# AUTH_LDAP_USER_FLAGS_BY_GROUP = {
61-
# "is_active": "cn=sftpusers,ou=groups,dc=yunohost,dc=org",
62-
# "is_staff": "cn=sftpusers,ou=groups,dc=yunohost,dc=org",
63-
# "is_superuser": "cn=sftpusers,ou=groups,dc=yunohost,dc=org"
64-
# }
65-
# AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=groups,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)")
66-
# AUTH_LDAP_GROUP_TYPE = PosixGroupType()
67-
# AUTH_LDAP_ALWAYS_UPDATE_USER = True
68-
# AUTH_LDAP_AUTHORIZE_ALL_USERS = True
69-
# AUTH_LDAP_FIND_GROUP_PERMS = True
70-
# #AUTH_LDAP_CACHE_GROUPS = True
71-
# #AUTH_LDAP_GROUP_CACHE_TIMEOUT = 300
72-
# #import logging
73-
# #logger = logging.getLogger('django_auth_ldap')
74-
# #logger.addHandler(logging.StreamHandler())
75-
# #logger.setLevel(logging.DEBUG)
40+
# Tous acces
41+
import ldap
42+
from django_auth_ldap.config import LDAPSearch, MemberDNGroupType
43+
AUTHENTICATION_BACKENDS = (
44+
'django_auth_ldap.backend.LDAPBackend',
45+
'django.contrib.auth.backends.ModelBackend',
46+
)
47+
AUTH_LDAP_SERVER_URI = "ldap://localhost:389"
48+
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
49+
AUTH_LDAP_USER_ATTR_MAP = {
50+
"username": "uid",
51+
"first_name": "givenName",
52+
"last_name": "sn",
53+
"email": "mail",
54+
}
55+
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
56+
"is_active": "cn={{ app }}.main,ou=permission,dc=yunohost,dc=org",
57+
"is_staff": "cn={{ app }}.staff,ou=permission,dc=yunohost,dc=org",
58+
"is_superuser": "cn={{ app }}.superadmin,ou=permission,dc=yunohost,dc=org"
59+
}
60+
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=permission,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE)
61+
AUTH_LDAP_GROUP_TYPE = MemberDNGroupType("inheritPermission", "permissionYnh")
62+
AUTH_LDAP_ALWAYS_UPDATE_USER = True
63+
AUTH_LDAP_AUTHORIZE_ALL_USERS = False
64+
AUTH_LDAP_FIND_GROUP_PERMS = True
65+
AUTH_LDAP_CACHE_GROUPS = True
66+
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 1000
67+
# import logging
68+
# logger = logging.getLogger('django_auth_ldap')
69+
# logger.addHandler(logging.StreamHandler())
70+
# logger.setLevel(logging.DEBUG)

manifest.toml

+23-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ ram.runtime = "50M"
3131
# this is a generic question - ask strings are automatically handled by Yunohost's core
3232
type = "domain"
3333

34-
[install.admin]
35-
# this is a generic question - ask strings are automatically handled by Yunohost's core
36-
type = "user"
37-
3834
[install.email]
3935
ask.en = "Choose email were send notification"
4036
ask.fr = "Choisissez l'email vers lequel envoyer les notifications"
@@ -53,6 +49,22 @@ ram.runtime = "50M"
5349
type = "string"
5450
example = "https://www.exemple.tld"
5551

52+
[install.init_staff_permission]
53+
ask.en = "Which group will have the staff access"
54+
ask.fr = "Quel groupe aura accès l'accès en tant que staff"
55+
help.en = "Users of this group should have access to the Coin admin page"
56+
help.fr = "Les utilisateurs de ce groupe devrait avoir accès à la page d'administration de Coin"
57+
type = "group"
58+
default = "admins"
59+
60+
[install.init_superadmin_permission]
61+
ask.en = "Which group will have the superadmin access"
62+
ask.fr = "Quel groupe aura accès l'accès en tant que super admin"
63+
help.en = "Users of this group should have all access on the Coin admin page"
64+
help.fr = "Les utilisateurs de ce groupe devrait avoir tout les accès sur la page d'administration de Coin"
65+
type = "group"
66+
default = "admins"
67+
5668
[resources]
5769
[resources.sources.main]
5870
url = "https://code.ffdn.org/ffdn/coin/-/archive/bcaad5f.tar.gz"
@@ -65,7 +77,13 @@ ram.runtime = "50M"
6577

6678
[resources.permissions]
6779
main.url = "/"
68-
main.allowed = "visitors"
80+
main.allowed = ["visitors", "all_users"]
81+
82+
staff.show_tile = false
83+
staff.label = "Staff"
84+
85+
superadmin.show_tile = false
86+
superadmin.label = "Super admin"
6987

7088
[resources.apt]
7189
packages = "gunicorn, python3, python3-venv, libpq-dev, libsasl2-dev, libjpeg-dev, libxml2-dev, libxslt1-dev, libpango1.0-0, postgresql, postgresql-contrib, postgresql-server-dev-all python3-dev"

scripts/install

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ynh_app_setting_set --app=$app --key=secret --value=$secret
99
#=================================================
1010
# DOWNLOAD, CHECK AND UNPACK SOURCE
1111
#=================================================
12-
ynh_script_progression --message="Setting up source files..."
12+
ynh_script_progression --message="Setting up source files..."
1313

1414
ynh_setup_source --dest_dir="$install_dir"
1515

@@ -22,20 +22,20 @@ chown -R $app:www-data "$install_dir"
2222
#=================================================
2323
# PYTHON DEPENDENCIES
2424
#=================================================
25-
ynh_script_progression --message="Installing more dependencies..."
25+
ynh_script_progression --message="Installing more dependencies..."
2626

2727
pushd "$install_dir"
2828
python3 -m venv venv
2929
venv/bin/pip install --upgrade pip
3030
venv/bin/pip install gunicorn
31-
#echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
31+
echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
3232
venv/bin/pip install -r requirements.txt
3333
popd
3434

3535
#=================================================
3636
# CONFIGURATION DJANGO
3737
#=================================================
38-
ynh_script_progression --message="Configuring application..."
38+
ynh_script_progression --message="Configuring application..."
3939

4040
export prefix="${path#"/"}/"
4141
prefix=${prefix%"/"}
@@ -65,7 +65,7 @@ chown -R $app:www-data "/var/log/$app"
6565
#=================================================
6666
# ADD A CONFIGURATION
6767
#=================================================
68-
ynh_script_progression --message="Adding a configuration file..."
68+
ynh_script_progression --message="Adding a configuration file..."
6969

7070
ynh_add_config --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
7171

@@ -88,7 +88,7 @@ yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.
8888
#=================================================
8989
# START SYSTEMD SERVICE
9090
#=================================================
91-
ynh_script_progression --message="Starting systemd service..."
91+
ynh_script_progression --message="Starting systemd service..."
9292

9393
# Start a systemd service
9494
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"

scripts/upgrade

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pushd "$install_dir"
3232
python3 -m venv venv
3333
venv/bin/pip install --upgrade pip
3434
venv/bin/pip install gunicorn
35-
#echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
35+
echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
3636
venv/bin/pip install -r requirements.txt
3737
popd
3838

0 commit comments

Comments
 (0)