跳至正文
Wener Notes

Kerberos & LDAP

约 3 分钟阅读
标签:服务认证授权KerberosLDAP

Kerberos & LDAP (X.500)

Kerberos

Packages

Configuration

krb5.conf:

ini
[libdefaults]
default_realm = EXAMPLE.COM

[realms]
EXAMPLE.COM = {
  admin_server = kerberos.example.com
  # Support DNS SRV
  kdc = kerberos.example.com
  # Not compatible with krb4 but more secure
  default_principal_flags = +preauth
}
bash
# Initialize principal
kinit wener

# Initialize with keytab
kinit -V -k -t /etc/krb5.keytab HTTP/[email protected]

Concepts

The Kerberos server of Apache Directory implements RFC 1510 and RFC 4120, the Kerberos V5 Network Authentication Service. The purpose of Kerberos is to verify the identities of principals (users or services) on an unprotected network.

While generally thought of as a single-sign-on technology, Kerberos's true strength is in authenticating users without ever sending their passwords over the network. Kerberos is designed for use in open (untrusted) networks and, therefore, operates under the assumption that packets traveling along the network can be read, modified, and inserted at will.

Kerberos is named after the three-headed dog that guards the gates to Hades. The three heads are the client, the Kerberos server, and the network service being accessed.

Principals:

macOS Issues

On macOS, the default client does not fall back to TCP. In your krb.conf, prefix your kdc value with tcp/ to force TCP:

ini
kdc = tcp/realm.example.com:88

LDAP

LDAP Attribute Types

StringX.500 AttributeType
CNcommonName
LlocalityName
STstateOrProvinceName
OorganizationName
OUorganizationalUnitName
CcountryName
STREETstreetAddress
DCdomainComponent
UIDuserid
bash
ldapmodify -h localhost -p 10389 -D "uid=admin,ou=system" -w secret -a -f marmoser-partition.ldif

KDC Tracing

bash
KRB5_TRACE=/dev/stdout kpasswd

Troubleshooting

Pre-authentication required

text
[21:39:17] ERROR [org.apache.directory.server.KERBEROS_LOG] - No timestamp found
[21:39:17] WARN [org.apache.directory.server.kerberos.protocol.KerberosProtocolHandler] - Additional pre-authentication required (25)

DIRKRB-99

AES256 Support

AES256 is not included by default in standard J2SE installation. You have to install JCE.

weak encryption

If ApacheDS uses weak encryption:

  1. Enable allow_weak_crypto = true in libdefaults.
  2. Or modify ads-krbEncryptionTypes in ApacheDS configuration.

Server not found

text
Server not found in Kerberos database while getting initial credentials

Check if the principal exists.

Example LDIF

text
dn: uid=keycloak,ou=services,dc=security,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
objectClass: krb5KDCEntry
objectClass: uidObject
objectClass: krb5Principal
krb5KeyVersionNumber: 0
krb5PrincipalName: HTTP/[email protected]
uid: kpasswd
userPassword:: randomkey
ou: Keycloak

Advanced krb5.conf

ini
[logging]
# default = FILE:/var/log/krb5libs.log
# kdc = FILE:/var/log/krb5kdc.log
# admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 dns_lookup_realm = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true
 rdns = false
default_realm = EXAMPLE.COM
allow_weak_crypto = true

[realms]
EXAMPLE.COM = {
  kdc = 192.168.36.8:60088
  kpasswd_server = 192.168.36.8:60464
}

[domain_realm]
 .example.com = EXAMPLE.COM
 example.com = EXAMPLE.COM

关联信息

反向链接、本文链接的其他页面和外部资料。

参考资料

Wikipedia1 条
标准文档1 条
  • RFC 2253datatracker.ietf.org/doc/html/rfc2253
    RFC

    IETF Request for Comments standard document.

其他外链14 条
最近更新commit 906e816编辑