External Authentication with Percona Server for MongoDB and MongoDB Enterprise
Jason Terpko DBA @ Rackspace/ObjectRocket linkedin.com/in/jterpko
1
External Authentication with Percona Server for MongoDB and MongoDB - - PowerPoint PPT Presentation
External Authentication with Percona Server for MongoDB and MongoDB Enterprise Jason Terpko DBA @ Rackspace/ObjectRocket linkedin.com/in/jterpko 1 Overview Percona Server For MongoDB o SASL and LDAP o MongoDB Enterprise o Kerberos and
Jason Terpko DBA @ Rackspace/ObjectRocket linkedin.com/in/jterpko
1
www.objectrocket.com
2
www.objectrocket.com
3
An enhanced free open source replacement for MongoDB Community Server SASL Authentication More Engine Options Hot Backup Auditing All MongoDB 3.4 Community Features
www.objectrocket.com
4
www.objectrocket.com
5
LDAP (Lightweight Directory Access Protocol) and Microsoft Active Directory # extended LDIF ... dn: uid=jason,ou=dba,dc=data,dc=com ... cn: jasonuid: jason uidNumber: 9999 gidNumber: 100 ... userPassword:: <secret> # extended LDIF ... dn: CN=Jason,OU=Users,DC=data,DC=com ... cn: Jason memberOf: CN=dba,OU=Mongo,DC=data,DC=com ... sAMAccountName: jason userPrincipalName: jason@data.com OpenLDAP Active Directory
www.objectrocket.com
6
PLAIN Auth Init SASL SASL Auth Yes/No Yes/No Yes Yes OK
www.objectrocket.com
7
/etc/sysconfig/saslauthd SOCKETDIR=/run/saslauthd MECH=ldap FLAGS="-O /etc/saslauthd.conf" /etc/mongos.conf security: keyFile: /etc/mongo.key setParameter: authenticationMechanisms: PLAIN,SCRAM-SHA-1
*LDAP Already Configured
www.objectrocket.com
8
/etc/saslauthd.conf ldap_servers: ldap://127.0.0.1:389 ldap_search_base: dc=data,dc=com ldap_filter: (uid=%u) ldap_bind_dn: uid=bind,ou=People,dc=data,dc=com ldap_password: <secret> /etc/sasl2/mongodb.conf pwcheck_method: saslauthd saslauthd_path: /var/run/saslauthd/mux log_level: 1 mech_list: plain
*LDAP Already Configured
www.objectrocket.com
9 db.getSiblingDB("$external").createUser({user : 'jason', roles: [ {role : "readWrite", db: 'prod'} ] }); db.getSiblingDB("$external").auth({mechanism: "PLAIN", "user": "jason", "pwd": ”secret", "digestPassword": false }); HelloWorld.py from pymongo import MongoClient # MongoDB Connection URI and Establish Connection uri = "mongodb://jason:terpko@localhost:27018/prod?authMechanism=PLAIN&authSource=$external” client = MongoClient(uri) …
www.objectrocket.com
10
www.objectrocket.com
11
An enterprise replacement for MongoDB Community Server All MongoDB 3.4 Community Features Ops Manager Optional Engines Enhanced Security Additional Software
www.objectrocket.com
12
www.objectrocket.com
13
TGT request Ticket GSSAPI OK Cache Validate OK
www.objectrocket.com
14
A session ticket that authenticates a client to Kerberos enabled host and services.
# klist krb5cc_12345 Ticket cache: FILE:krb5cc_12345 Default principal: jason@DATA.COM Valid starting Expires Service principal 01/01/2017 05:28:34 01/01/2017 17:28:34 krbtgt/DATA.COM@DATA.COM renew until 01/08/2017 05:28:34
User Ticket Cache:
*Active Directory Configured **Client Kerberos Configured
www.objectrocket.com
15 env KRB5_KTNAME=<path to keytab file> mongod -f /etc/mongod.conf
Starting MongoD with Kerberos Service Principle
# klist Ticket cache: FILE:krb5cc_0 … Valid starting Expires Service principal 01/01/2017 05:28:34 01/01/2017 17:28:34 mongodb/server1.data.com@DATA.COM renew until 01/08/2017 05:28:34
www.objectrocket.com
16
security: authorization: enabled keyFile: /etc/mongo.key ldap: authz: queryTemplate: DC=DATA,DC=COM??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER})) bind: method: simple queryPassword: <secret> queryUser: bind@data.com servers: ldap.data.com:636 transportSecurity: tls userToDNMapping: '[{match : "(.+)",ldapQuery:"DC=DATA,DC=COM??sub?(userPrincipalName={0})"}]' setParameter: authenticationMechanisms: GSSAPI
/etc/mongod.conf
www.objectrocket.com
17
security: authorization: enabled keyFile: /etc/mongo.key ldap: authz: queryTemplate: DC=DATA,DC=COM??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER})) bind: method: simple queryPassword: <secret> queryUser: bind@data.com servers: ldap.data.com:636 transportSecurity: tls userToDNMapping: '[{match : "(.+)",ldapQuery:"DC=DATA,DC=COM??sub?(userPrincipalName={0})"}]' setParameter: authenticationMechanisms: GSSAPI
/etc/mongod.conf
www.objectrocket.com
18
security: authorization: enabled keyFile: /etc/mongo.key ldap: authz: queryTemplate: DC=DATA,DC=COM??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER})) bind: method: simple queryPassword: <secret> queryUser: bind@data.com servers: ldap.data.com:636 transportSecurity: tls userToDNMapping: '[{match : "(.+)",ldapQuery:"DC=DATA,DC=COM??sub?(userPrincipalName={0})"}]' setParameter: authenticationMechanisms: GSSAPI
/etc/mongod.conf
www.objectrocket.com
19
Cache Authz request LDAP Query memberOf Authorized
www.objectrocket.com
20 db.getSiblingDB("admin").createRole( { role: "CN=dba,DC=data,DC=com", privileges: [], roles: [ "userAdminAnyDatabase", "readWriteAnyDatabase", "dbAdminAnyDatabase", "clusterAdmin" ] }); db.getSiblingDB("$external").auth({mechanism: "GSSAPI", "user": "jason@DATA.COM" });
HelloWorld.py from pymongo import MongoClient # MongoDB Connection URI and Establish Connection uri="mongodb://jason%40DATA.COM@server1.data.com:27017,.../?replicaSet=rs1&authMechanism=GSSAPI&ssl=true” client=MongoClient(uri) …
www.objectrocket.com
21
Alternatively manage your deployment with Ops Manager.
www.objectrocket.com
22
www.objectrocket.com
23
www.objectrocket.com
24
Address: 100 Congress Ave Suite 400 Austin, TX 78701 Support: 1-800-961-4454 Sales: 1-888-440-3242 www.objectrocket.com
25