Skip to content

Commit

Permalink
Updated configuration, container's comunication done using IPs instea…
Browse files Browse the repository at this point in the history
…d of --link
  • Loading branch information
valdar committed Apr 2, 2015
1 parent c0ed9fa commit 548a92f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# Jboss Fuse Ldap authentication lab
`sh fuseLdap.sh`

This is a simple script that run for you 3 docker images:
- OpenLdap with preloaded users/groups data: valdar/ldapfuseusers:1.0.0
- PhpLdapAdmin (just to have a convenient way to visualize/modifiy ldap contents): osixia/phpldapadmin:0.5.0
- Jbosse fuse (you need to build this image yourself): https://github.com/paoloantinori/dockerfiles/tree/master/centos/fuse
- address: `localhost:389` admin dn: `cn=admin,dc=example,dc=org` admin password: `admin`
- PhpLdapAdmin (just to have a convenient way to visualize/modifiy ldap contents): osixia/phpldapadmin:0.5.0
- address: `https://localhost` admin dn: `cn=admin,dc=example,dc=org` admin password: `admin`
- Jbosse fuse (**you need to build this image yourself**): https://github.com/paoloantinori/dockerfiles/tree/master/centos/fuse

After that it creates a fabric and update the configuration to authenticate using the openldap server. In this way you will be able to log in in to karaf console or hawtio using credentials stored in openldap:
- user: `fuseldap` password: `fuseldap` group: `admin`
- user: `notfuseldap` password: `notfuseldap` group: `none`

when the script finish you should be able to check fuse container's local ports with:
## Interacting with the Fuse container
When the script finish you should be able to check fuse container's local ports with:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e996ab8e080 fuse6.1:latest "/bin/sh -c 'service About an hour ago Up About an hour 0.0.0.0:49153->44444/tcp, 0.0.0.0:49154->61616/tcp, 0.0.0.0:49155->8101/tcp, 0.0.0.0:49156->8181/tcp, 0.0.0.0:49157->1099/tcp, 0.0.0.0:49158->22/tcp root
398aa9b12fc8 osixia/phpldapadmin:0.5.0 "/sbin/my_init" About an hour ago Up About an hour 80/tcp, 0.0.0.0:443->443/tcp phpldapadmin
38b8e0885dbf valdar/ldapfuseusers:1.0.0 "/sbin/my_init" About an hour ago Up About an hour 0.0.0.0:389->389/tcp openldap
```
in this example the hawtio console would be at `http://localhost:49156`, activeMQ at `localhost:49154`, karaf console at `localhost:49155` and ssh into the container at `localhost:49158`.

## NOTE Before launching the script:
Before launching the script you need to build fuse6.1 image yourself by download JBoss Fuse distribution from

Expand Down
11 changes: 9 additions & 2 deletions fuseLdap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ set -e

# create your lab
docker run -t -i -p 389:389 -e SERVER_NAME=ldap.my-compagny.com --name openldap -d valdar/ldapfuseusers:1.0.0
docker run -t -i -p 443:443 --link openldap:openldapserver -e LDAP_HOSTS=openldapserver --name phpldapadmin -d osixia/phpldapadmin
docker run -d -t -i $EXPOSE_PORTS --link openldap:openldapserver --name root fuse6.1
# assign ip addresses to env variable, despite they should be constant on the same machine across sessions
IP_LDAP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' openldap)
docker run -t -i -p 443:443 -e LDAP_HOSTS=$IP_LDAP --name phpldapadmin -d osixia/phpldapadmin
docker run -d -t -i $EXPOSE_PORTS --name root fuse6.1

# assign ip addresses to env variable, despite they should be constant on the same machine across sessions
IP_ROOT=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' root)
Expand Down Expand Up @@ -118,6 +120,9 @@ git checkout 1.1

#add xml ldap configuration to versio 1.1. of default profile
cp ../ldap-module.xml fabric/profiles/default.profile/
#add configuration of ldaphost
touch fabric/profiles/default.profile/ldap.server.properties
echo "ldaphostserver=$IP_LDAP" >> fabric/profiles/default.profile/ldap.server.properties
#add a config line to io.fabric8.agent.properties in versio 1.1. of default profile
printf "\nbundle.ldap-realm=blueprint:profile:ldap-module.xml" >> fabric/profiles/default.profile/io.fabric8.agent.properties

Expand All @@ -129,5 +134,7 @@ git push origin 1.1
cd ..
rm -rf ./tmp-git

sleep 5

#upgrade root container to the new configuration
ssh2fabric "fabric:container-upgrade --all 1.1"
22 changes: 15 additions & 7 deletions ldap-module.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">


<cm:property-placeholder persistent-id="ldap.server" update-strategy="none" >
<cm:default-properties>
<cm:property name="ldaphostserver" value="localhost"/>
</cm:default-properties>
</cm:property-placeholder>
<jaas:config name="karaf" rank="10">
<jaas:module className="io.fabric8.jaas.ZookeeperLoginModule"
flags="sufficient">
</jaas:module>
<jaas:module className="org.apache.karaf.jaas.modules.ldap.LDAPLoginModule"
flags="sufficient">
<jaas:module className="io.fabric8.jaas.ZookeeperLoginModule" flags="sufficient"/>
<jaas:module className="org.apache.karaf.jaas.modules.ldap.LDAPLoginModule" flags="sufficient">
initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory
connection.username=cn=admin,dc=example,dc=org
connection.password=admin
connection.protocol=
connection.url=ldap://openldapserver:389
connection.url=ldap://${ldaphostserver}:389
user.base.dn=ou=People,dc=example,dc=org
user.filter=(uid=%u)
user.search.subtree=true
Expand Down

0 comments on commit 548a92f

Please sign in to comment.