Basic LDAP config

Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
Georg Pfuetzenreuter 2022-01-08 16:24:22 +01:00
parent 325a234b18
commit 6297a57522
Signed by: Georg
GPG Key ID: 1DAF57F49F8E8F22
10 changed files with 115 additions and 0 deletions

27
api/website/ldap.py Normal file
View File

@ -0,0 +1,27 @@
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
AUTH_LDAP_SERVER_URI = "ldaps://foo.example.com ldaps://bar.example.com"
AUTH_LDAP_BIND_DN = "cn=foo,ou=bar,dc=example,dc=com"
AUTH_LDAP_BIND_PASSWORD = "foobar"
AUTH_LDAP_USER_SEARCH = LDAPSearch(
"ou=foo-users,dc=example,dc=com", ldap.SCOPE_ONELEVEL, "(&(uid=%(user)s)(objectClass=nsPerson)(|(memberOf=cn=foo_access,ou=bar,dc=example,dc=com)(memberOf=cn=foo_staff,ou=bar,dc=example,dc=com)(memberOf=cn=foo_admins,ou=bar,dc=example,dc=com)))"
)
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"full_name": "legalName",
"email": "mail",
}
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
"ou=bar,dc=example,dc=com", ldap.SCOPE_ONELEVEL, "(&(objectClass=groupOfNames)(|(cn=foo_access)(cn=foo_staff)(cn=foo_admins)))"
)
AUTH_LDAP_REQUIRE_GROUP = "cn=foo_access,ou=foo_groups,dc=syscid,dc=com"
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_active": "cn=foo_access,ou=foo_groups,dc=example,dc=com",
"is_staff": "cn=foo_staff,ou=foo_groups,dc=example,dc=com",
"is_superuser": "cn=foo_admins,ou=foo_groups,groups,dc=example,dc=com"
}
AUTH_LDAP_FIND_GROUP_PERMS = True
AUTH_LDAP_CACHE_TIMEOUT = 3600

View File

@ -186,3 +186,12 @@ REST_FRAMEWORK = {
# }, # },
# }, # },
# } # }
REMOTE_AUTH_ENABLED = True
REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'
REMOTE_AUTH_HEADER = 'HTTP_REMOTE_USER'
REMOTE_AUTH_AUTO_CREATE_USER = True
REMOTE_AUTH_DEFAULT_GROUPS = []
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
SESSION_COOKIE_NAME = 'libertacasa-dev'

View File

@ -0,0 +1 @@
<!DOCTYPE html><html><head><title>https://liberta.casa/about/</title><link rel="canonical" href="https://liberta.casa/about/"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=https://liberta.casa/about/" /></head></html>

View File

@ -0,0 +1 @@
<!DOCTYPE html><html><head><title>https://liberta.casa/about/</title><link rel="canonical" href="https://liberta.casa/about/"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=https://liberta.casa/about/" /></head></html>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Categories on Liberta Casa</title>
<link>https://liberta.casa/categories/</link>
<description>Recent content in Categories on Liberta Casa</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language><atom:link href="https://liberta.casa/categories/index.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>

View File

@ -0,0 +1 @@
<!DOCTYPE html><html><head><title>https://liberta.casa/about/</title><link rel="canonical" href="https://liberta.casa/about/"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=https://liberta.casa/about/" /></head></html>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Liberta Casa</title>
<link>https://liberta.casa/</link>
<description>Recent content on Liberta Casa</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language><atom:link href="https://liberta.casa/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>About</title>
<link>https://liberta.casa/about/</link>
<pubDate>Sun, 12 Dec 2021 00:00:00 +0000</pubDate>
<guid>https://liberta.casa/about/</guid>
<description></description>
</item>
<item>
<title>Rules</title>
<link>https://liberta.casa/rules/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://liberta.casa/rules/</guid>
<description></description>
</item>
</channel>
</rss>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Series on Liberta Casa</title>
<link>https://liberta.casa/series/</link>
<description>Recent content in Series on Liberta Casa</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language><atom:link href="https://liberta.casa/series/index.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://liberta.casa/about/</loc>
<lastmod>2021-12-12T00:00:00+00:00</lastmod>
</url><url>
<loc>https://liberta.casa/</loc>
</url><url>
<loc>https://liberta.casa/categories/</loc>
</url><url>
<loc>https://liberta.casa/rules/</loc>
</url><url>
<loc>https://liberta.casa/series/</loc>
</url><url>
<loc>https://liberta.casa/tags/</loc>
</url>
</urlset>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Tags on Liberta Casa</title>
<link>https://liberta.casa/tags/</link>
<description>Recent content in Tags on Liberta Casa</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language><atom:link href="https://liberta.casa/tags/index.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>