Moved kerberos services to kerberos-services exported variable

master
noah metz 2023-12-03 13:19:12 -07:00
parent 5d42b8e470
commit afc0f17da0
1 changed files with 84 additions and 97 deletions

@ -27,25 +27,24 @@
#:use-module (gnu services configuration) #:use-module (gnu services configuration)
#:use-module (gnu services certbot) #:use-module (gnu services certbot)
#:export (kerberos.metznet.ca)) #:export (kerberos.metznet.ca kerberos-services))
(define-public mit-krb5-ldap (define-public mit-krb5-ldap
(package (package
(name "mit-krb5-ldap") (name "mit-krb5-ldap")
(version "1.20") (version "1.20")
(source (origin (source
(method url-fetch) (origin
(uri (list (string-append (method url-fetch)
"https://web.mit.edu/kerberos/dist/krb5/" (uri (list (string-append "https://web.mit.edu/kerberos/dist/krb5/"
(version-major+minor version) "/krb5-" version (version-major+minor version) "/krb5-"
".tar.gz") version ".tar.gz")
(string-append "https://kerberos.org/dist/krb5/" (string-append "https://kerberos.org/dist/krb5/"
(version-major+minor version) "/krb5-" (version-major+minor version) "/krb5-"
version ".tar.gz"))) version ".tar.gz")))
(patches (search-patches "mit-krb5-hurd.patch")) (patches (search-patches "mit-krb5-hurd.patch"))
(sha256 (sha256
(base32 (base32 "0bz16sh0vgzlpy2kx5acmpyy181hl83a1alz7wbk06457kfjn0ky"))))
"0bz16sh0vgzlpy2kx5acmpyy181hl83a1alz7wbk06457kfjn0ky"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(native-inputs (list bison perl tcl openldap-slapd)) ;required for some tests (native-inputs (list bison perl tcl openldap-slapd)) ;required for some tests
(inputs (list openssl readline)) (inputs (list openssl readline))
@ -130,27 +129,20 @@
"") "")
(define-configuration kdc-realm-configuration (define-configuration kdc-realm-configuration
(name (string "EXAMPLE.COM") "realm name" serialize-none) (name (string "EXAMPLE.COM") "realm name" serialize-none)
(database_module maybe-string "database module") (database_module maybe-string "database module")
(acl_file maybe-file-like "acl file") (acl_file maybe-file-like "acl file")
(key_stash_file (string "/var/lib/kerberos/stash") (key_stash_file (string "/var/lib/kerberos/stash") "key stash file")
"key stash file") (kdc_ports (list-of-ports '(750 88)) "list of ports to listen on"
(kdc_ports (list-of-ports '(750 88)) realm-serialize-list-of-ports)
"list of ports to listen on" (kadmind_ports (list-of-ports '(749))
realm-serialize-list-of-ports) "list of ports to listen on for kadmin connections"
(kadmind_ports (list-of-ports '(749)) realm-serialize-list-of-ports)
"list of ports to listen on for kadmin connections" (max_life (string "10h 0m 0s") "maximum life of granted tickets")
realm-serialize-list-of-ports) (max_renewable_type (string "7d 0h 0m 0s") "maximum time to renew ticket")
(max_life (string "10h 0m 0s") (master_key_type (string "des3-hmac-sha1") "master key type")
"maximum life of granted tickets") (supported_enctypes maybe-string "supported encryption types")
(max_renewable_type (string "7d 0h 0m 0s") (default_principal_flags maybe-string "default flag for new principals"))
"maximum time to renew ticket")
(master_key_type (string "des3-hmac-sha1")
"master key type")
(supported_enctypes maybe-string
"supported encryption types")
(default_principal_flags maybe-string
"default flag for new principals"))
(define list-of-kdc-realm-configuration? (define list-of-kdc-realm-configuration?
(list-of kdc-realm-configuration?)) (list-of kdc-realm-configuration?))
@ -169,20 +161,17 @@
(serialize-field number->string " ")) (serialize-field number->string " "))
(define-configuration kldap-configuration (define-configuration kldap-configuration
(db_library (string "kldap") "db library to use") (db_library (string "kldap") "db library to use")
(disable_last_success (boolean #f) (disable_last_success (boolean #f) "disable last success field")
"disable last success field") (disable_lockout (boolean #f) "disable lockout field")
(disable_lockout (boolean #f) "disable lockout field") (ldap_kdc_dn (string "uid=kdc,dc=example,dc=com")
(ldap_kdc_dn (string "uid=kdc,dc=example,dc=com") "dn to bind for kdc operations")
"dn to bind for kdc operations") (ldap_kadmind_dn (string "uid=kadmind,dc=example,dc=com")
(ldap_kadmind_dn (string "uid=kadmind,dc=example,dc=com") "dn to bind for kadmin operations")
"dn to bind for kadmin operations") (ldap_service_password_file maybe-file-like
(ldap_service_password_file maybe-file-like "file that stores the passwords for the ldap bind dns")
"file that stores the passwords for the ldap bind dns") (ldap_servers (string "ldap://example.com") "ldap server url")
(ldap_servers (string "ldap://example.com") (ldap_conns_per_server (number 5) "number of connections per ldap server"))
"ldap server url")
(ldap_conns_per_server (number 5)
"number of connections per ldap server"))
(define (serialize-list-of-kdc-realm-configuration field-name value) (define (serialize-list-of-kdc-realm-configuration field-name value)
#~(string-join (list "[realms]" #~(string-join (list "[realms]"
@ -226,22 +215,17 @@
(define-maybe list-of-strings) (define-maybe list-of-strings)
(define-configuration kdc-configuration (define-configuration kdc-configuration
(krb5 (file-like mit-krb5-ldap) "krb5 package to use" (krb5 (file-like mit-krb5-ldap) "krb5 package to use" serialize-none)
serialize-none) (pkinit_anchors (string "DIR:/run/current-system/profile/etc/ssl/certs/")
(pkinit_anchors (string "CA certificate directory/file"
"DIR:/run/current-system/profile/etc/ssl/certs/") (serialize-field (lambda (x)
"CA certificate directory/file" x) " "))
(serialize-field (lambda (x) (kdc_ports (list-of-ports '(750 88)) "list of ports to listen on")
x) " ")) (realms (list-of-kdc-realm-configuration '())
(kdc_ports (list-of-ports '(750 88)) "Realms to configure the KDC with")
"list of ports to listen on") (logging maybe-list-of-strings "extra logging lines")
(realms (list-of-kdc-realm-configuration '()) (dbdefaults maybe-list-of-strings "extra dbdefault lines")
"Realms to configure the KDC with") (dbmodules (list-of-dbmodules '()) "dbmodules to configure"))
(logging maybe-list-of-strings "extra logging lines")
(dbdefaults maybe-list-of-strings
"extra dbdefault lines")
(dbmodules (list-of-dbmodules '())
"dbmodules to configure"))
(define (serialize-kdc-configuration configuration) (define (serialize-kdc-configuration configuration)
(mixed-text-file "kdc.conf" (mixed-text-file "kdc.conf"
@ -328,40 +312,43 @@
(define %kerberos-dn (define %kerberos-dn
"uid=kerberos,ou=system,ou=accounts,dc=metznet,dc=ca") "uid=kerberos,ou=system,ou=accounts,dc=metznet,dc=ca")
(define-public kerberos-services
(append (list (service kdc-service-type
(kdc-configuration (dbdefaults '("ldap_kerberos_container_dn = cn=kerberos,dc=metznet,dc=ca"))
(logging '("kdc = SYSLOG:DEBUG:DAEMON"))
(dbmodules (list (cons
"openldap_ldapconf"
(kldap-configuration
(ldap_kdc_dn
%kerberos-dn)
(ldap_kadmind_dn
%kerberos-dn)
(ldap_servers
"ldaps://ldap.metznet.ca")
(ldap_service_password_file
(plain-file
"service.keyfile"
"uid=kerberos,ou=system,ou=accounts,dc=metznet,dc=ca#{HEX}594459525a793139
"))))))
(realms (list (kdc-realm-configuration
(name "METZNET.CA")
(database_module
"openldap_ldapconf")
(default_principal_flags
"+preauth")
(acl_file (plain-file
"kadm5.acl"
"*/admin@METZNET.CA *\n")))))))
(service certbot-service-type
(certbot-configuration (email "admin@metznet.ca")
(certificates (list (certificate-configuration
(domains '
("kerberos.guix.metznet.ca"))))))))
%metznet-server-services))
(define-public kerberos.metznet.ca (define-public kerberos.metznet.ca
(operating-system (operating-system
(inherit %metznet-base-server-system) (inherit %metznet-base-server-system)
(host-name "kerberos.guix.metznet.ca") (host-name "kerberos.guix.metznet.ca")
(services (services
(append (list (service kdc-service-type kerberos-services)))
(kdc-configuration (dbdefaults '("ldap_kerberos_container_dn = cn=kerberos,dc=metznet,dc=ca"))
(logging '("kdc = SYSLOG:DEBUG:DAEMON"))
(dbmodules (list (cons
"openldap_ldapconf"
(kldap-configuration
(ldap_kdc_dn
%kerberos-dn)
(ldap_kadmind_dn
%kerberos-dn)
(ldap_servers
"ldaps://ldap.metznet.ca")
(ldap_service_password_file
(plain-file
"service.keyfile"
"uid=kerberos,ou=system,ou=accounts,dc=metznet,dc=ca#{HEX}594459525a793139\n"))))))
(realms (list (kdc-realm-configuration
(name
"METZNET.CA")
(database_module
"openldap_ldapconf")
(default_principal_flags
"+preauth")
(acl_file (plain-file
"kadm5.acl"
"*/admin@METZNET.CA *\n")))))))
(service certbot-service-type
(certbot-configuration (email "admin@metznet.ca")
(certificates (list (certificate-configuration
(domains '
("kerberos.guix.metznet.ca"))))))))
%metznet-server-services))))