Sign inSign up

locaweb/docker-sentry-ldap

By locaweb

•Updated over 6 years ago

Docker image for sentry LDAP

Image
0

5.5K

locaweb/docker-sentry-ldap repository overview

⁠docker-sentry-ldap

⁠History

The work here is based on slafs sentry repo⁠ and banno⁠ this Dockerfile is an extension of the sentry official docker image⁠ so, any ENVIRONMENT documented there you can use here.

I guess that slafs⁠ stopped his word after Sentry releases their official Docker image, but for some reason, the image do not support LDAP stuff so we merged both and make it work.

Update 2019-08: Sentry released the 9 version with better customization support from the -ondemand we are now using this image as a source for ours.

⁠Notes on version 9.1

Unfortunately sentry run web don't support the parameter -b 0:$PORT0 where $PORT0 is the variable that your docker orchestrator fill with the currently available port to map, the official conf only support the 9000 port.

So we create a env var called $PORT0 that you can pass your alternative port, the default is 9000 but if you use Kubernetes or other orchestrators you probably need to use $PORT0 env

⁠Example environment configuration

Environment variable nameValue
LDAP_BIND_DNuid=sentry,ou=Systems,dc=server,dc=com
LDAP_BIND_PASSWORDfeijoada
LDAP_GROUP_TYPEgroupOfUniqueNames
LDAP_MAP_FIRST_NAMEcn
LDAP_SERVERldaps://ldap.server.com:636
LDAP_USER_DNou=Employees,dc=company,dc=com
LDAP_USER_FILTER=(&(objectClass=inetOrgPerson)(mail=%(user)s))
LDAP_DEFAULT_SENTRY_ORGANIZATIONLocaweb
SENTRY_DB_NAMEsentry
SENTRY_DB_PASSWORDdbpasswd
SENTRY_DB_USERsentry
SENTRY_EMAIL_HOSTemail.relay.com
SENTRY_EMAIL_PORT25
SENTRY_MEMCACHED_HOSTmemcached_farm.server.com
SENTRY_MEMCACHED_PORT11211
SENTRY_POSTGRES_HOSTpostgres.server.com
SENTRY_REDIS_HOSTredis.server.com
SENTRY_REDIS_PORT11042
SENTRY_SECRET_KEYsecret_sentry_key_42
SENTRY_SERVER_EMAIL[email protected]⁠
SENTRY_USE_LDAPTrue

⁠Available environment variables

Refer to sentry documentation⁠, django documentation⁠, celery documentation⁠ and django-auth-ldap documentation⁠ for the meaning of each setting.

Environment variable nameDjango/Sentry settingTypeDefault valueDescription
SENTRY_USE_LDAPboolFalseif set to False all other LDAP settings are discarded
LDAP_SERVERAUTH_LDAP_SERVER_URIldap://localhostExample: ldaps://ldap.locaweb.com:639
LDAP_BIND_DNAUTH_LDAP_BIND_DN''The user used to login at ldap, normally this is a system user example: uid=sentry,ou=Systems,dc=locaweb,dc=com
LDAP_BIND_PASSWORDAUTH_LDAP_BIND_PASSWORD''The password of the user
LDAP_USER_DNAUTH_LDAP_USER_SEARCH*REQUIRED! if you want to use LDAP authfirst argument of LDAPSearch (base_dn) when searching for users
LDAP_USER_FILTERAUTH_LDAP_USER_SEARCH*(&(objectClass=inetOrgPerson)(cn=%(user)s))third argument of LDAPSearch (filterstr) when searching for users
LDAP_GROUP_DNAUTH_LDAP_GROUP_SEARCH*''first argument of LDAPSearch (base_dn) when searching for groups
LDAP_GROUP_FILTERAUTH_LDAP_GROUP_SEARCH*(objectClass=groupOfUniqueNames)third argument of LDAPSearch (filterstr) when searching for groups
LDAP_GROUP_TYPEAUTH_LDAP_GROUP_TYPE*''if set to 'groupOfUniqueNames' then AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType(), if set to 'posixGroup' then AUTH_LDAP_GROUP_TYPE = PosixGroupType().
LDAP_DEFAULT_SENTRY_ORGANIZATIONAUTH_LDAP_DEFAULT_SENTRY_ORGANIZATIONLocawebName of the Sentry Default Organization
LDAP_REQUIRE_GROUPAUTH_LDAP_REQUIRE_GROUPNone
LDAP_DENY_GROUPAUTH_LDAP_DENY_GROUPNone
LDAP_MAP_FULL_NAMEAUTH_LDAP_USER_ATTR_MAP['first_name']cnPlease make sure that this property have the full name of the user
LDAP_MAP_MAILAUTH_LDAP_USER_ATTR_MAP['email']mail
LDAP_SENTRY_USER_FIELDmailWhich LDAP field will be used to create the Sentry username
LDAP_GROUP_ACTIVEAUTH_LDAP_USER_FLAGS_BY_GROUP['is_active']''
LDAP_GROUP_STAFFAUTH_LDAP_USER_FLAGS_BY_GROUP['is_staff']''
LDAP_GROUP_SUPERUSERAUTH_LDAP_USER_FLAGS_BY_GROUP['is_superuser']''
LDAP_FIND_GROUP_PERMSAUTH_LDAP_FIND_GROUP_PERMSboolFalse
LDAP_CACHE_GROUPSAUTH_LDAP_CACHE_GROUPSboolTrue
LDAP_GROUP_CACHE_TIMEOUTAUTH_LDAP_GROUP_CACHE_TIMEOUTint3600
LDAP_LOGLEVELDEBUGdjango_auth_ldap logger level (other values: NOTSET (to disable), INFO, WARNING, ERROR or CRITICAL)

⁠Health-check

⁠Web

Just check the localhost:9000/_health/ of your container

⁠Workers

Use celery ping command:

$ sentry exec -c 'import celery, os; print(celery.task.control.inspect().ping().get("celery@{}".format(os.environ["HOSTNAME"]))["ok"])'

This will check if the celery daemon that is running on that host, is ok.

⁠Build

$ docker build -t "$DOCKER_REGISTRY_URL/sentry/sentry:9.1" .

Tag summary

Content type

Image

Digest

Size

172.5 MB

Last updated

over 6 years ago

docker pull locaweb/docker-sentry-ldap:8.21