Sergiusz Bazanski | d0ec2c6 | 2019-11-21 00:08:52 +0100 | [diff] [blame] | 1 | local mirko = import "../../kube/mirko.libsonnet"; |
| 2 | local kube = import "../../kube/kube.libsonnet"; |
| 3 | |
| 4 | { |
| 5 | cfg:: { |
| 6 | # Manually built from code.hackerspace.pl/q3k/ldap-web-public. |
Serge Bazanski | fceedd1 | 2020-08-15 20:42:46 +0200 | [diff] [blame] | 7 | image: "registry.k0.hswaw.net/q3k/ldap-web:1597515993", |
Sergiusz Bazanski | d0ec2c6 | 2019-11-21 00:08:52 +0100 | [diff] [blame] | 8 | webFQDN: error "webFQDN must be set!", |
| 9 | }, |
| 10 | |
| 11 | component(cfg, env): mirko.Component(env, "ldapweb") { |
| 12 | local ldapweb = self, |
| 13 | cfg+: { |
| 14 | image: cfg.image, |
| 15 | volumes+: { |
| 16 | config: kube.ConfigMapVolume(ldapweb.configmap), |
| 17 | }, |
| 18 | container: ldapweb.Container("main") { |
| 19 | # Starts by default on port 8000. |
| 20 | volumeMounts_+: { |
| 21 | config: { mountPath: "/app/webapp/config.py", subPath: "config.py", }, |
| 22 | }, |
| 23 | }, |
| 24 | ports+: { |
| 25 | publicHTTP: { |
| 26 | web: { |
| 27 | port: 8000, |
| 28 | dns: cfg.webFQDN, |
| 29 | }, |
| 30 | }, |
| 31 | }, |
| 32 | }, |
| 33 | |
| 34 | configmap: kube.ConfigMap(ldapweb.makeName("config")) { |
| 35 | metadata+: ldapweb.metadata, |
| 36 | data: { |
| 37 | "config.py": ||| |
| 38 | # -*- coding: utf-8 -*- |
| 39 | import flask_wtf |
| 40 | import wtforms |
| 41 | ldap_url = 'ldap://ldap.hackerspace.pl' |
| 42 | dn_format = "uid=%s,ou=people,dc=hackerspace,dc=pl" |
| 43 | |
| 44 | admin_dn = 'cn=ldapweb,ou=Services,dc=hackerspace,dc=pl' |
| 45 | admin_pw = 'unused' |
| 46 | |
| 47 | hackerspace_name = 'Warsaw Hackerspace' |
| 48 | |
| 49 | readable_names = { |
| 50 | 'commonname': u'Common Name', |
| 51 | 'givenname': u'Given Name', |
| 52 | 'gecos': u'GECOS (public name)', |
| 53 | 'surname': u'Surname', |
| 54 | 'loginshell': u'Shell', |
| 55 | 'telephonenumber': 'Phone Number', |
| 56 | 'mobiletelephonenumber': 'Mobile Number', |
| 57 | 'sshpublickey': 'SSH Public Key', |
| 58 | } |
| 59 | |
| 60 | full_name = { |
| 61 | 'cn': 'commonname', |
| 62 | 'gecos': 'gecos', |
| 63 | 'sn': 'surname', |
| 64 | 'mobile': 'mobiletelephonenumber', |
| 65 | 'l': 'locality', |
| 66 | } |
| 67 | |
| 68 | can_add = set([ |
| 69 | 'telephonenumber', |
| 70 | 'mobiletelephonenumber', |
| 71 | 'sshpublickey', |
| 72 | ]) |
| 73 | can_delete = can_add |
| 74 | can_modify = can_add | set([ |
| 75 | 'givenname', 'surname', 'commonname', 'gecos', |
| 76 | ]) |
| 77 | can = { 'add':can_add, 'mod':can_modify, 'del':can_delete } |
| 78 | admin_required = set() |
| 79 | |
| 80 | |
| 81 | perm_errors = { |
| 82 | 'add': 'You cannot add this attribute!', |
| 83 | 'mod': 'You cannot change this attribute!', |
| 84 | 'del': 'You cannot delete this attribute!', |
| 85 | } |
| 86 | std_templates = { |
| 87 | 'add': 'ops/add.html', |
| 88 | 'mod': 'ops/mod.html', |
| 89 | 'del': 'ops/del.html', |
| 90 | } |
| 91 | |
| 92 | |
| 93 | |
| 94 | default_field = (wtforms.fields.StringField, {}) |
| 95 | fields = { 'telephonenumber': (wtforms.fields.StringField, {'validators': [wtforms.validators.Regexp(r'[+0-9 ]+')]})} |
| 96 | |
| 97 | kadmin_passwd = True |
| 98 | kadmin_principal_map = "{}@HACKERSPACE.PL" |
| 99 | |
| 100 | TOKEN_LENGTH = 32 |
| 101 | |||, |
| 102 | }, |
| 103 | }, |
| 104 | }, |
| 105 | } |