Skip to content
This repository was archived by the owner on Dec 18, 2020. It is now read-only.

Commit 695da25

Browse files
ckessablrivallain
authored andcommitted
add: ui extension
1 parent c15b28e commit 695da25

36 files changed

+1745
-50
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
**/__pycache__/
33
# Avoid pushing real configuration
44
api/config.json
5+
6+
#ui
7+
node_modules
8+
dist
9+
package-lock.json

README.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ A this time, the extension supports only **users management** with the following
1414
* Reset password
1515
* Delete user
1616

17+
LUMExt support both LDAP or LDAPs protocols and, at least, *Active Directory* based LDAP server.
18+
1719
### Todo
1820

1921
In future releases, we plan to provide a support for LDAP **groups** to simplify the role management:
@@ -52,7 +54,7 @@ LUMExt is based on a the [vCloud Director Extension SDK](https://github.com/vmwa
5254

5355
The following architecture is used for LUMExt deployement
5456

55-
![Architecture overview](./docs/images/architecture.svg)
57+
![Architecture overview](./docs/images/architecture_overview.png)
5658

5759
### LDAP structure
5860

@@ -78,6 +80,10 @@ Each Organization's OU is named according to the Org-ID (ex: `5eb80c89-06bc-4650
7880

7981
*Base OU* can be configured in the settings of LUMExt API service to point in a specific point of the LDAP directory based on its LDAP path.
8082

83+
Example of a LDAP structure in an *Active Directory* server:
84+
85+
![LDAP Structure example](./docs/images/ldap_structure_example.png)
86+
8187
## LUMExt-API
8288

8389
*LUMExt-API* is the backend server used to:
@@ -102,7 +108,7 @@ yum install git
102108

103109
# Create env variable
104110
echo "export LUMEXT_HOME=/opt/sii/lumext" > /etc/profile.d/lumext.sh
105-
echo "export LUMEXT_CONFIGURATION_FILE_PATH=/opt/sii/lumext/etc/config.json" >> /etc/profile.d/lumext.sh
111+
echo "export LUMEXT_CONFIGURATION_FILE_PATH=/opt/sii/lumext/etc/config.yaml" >> /etc/profile.d/lumext.sh
106112
chmod 755 /etc/profile.d/lumext.sh
107113

108114
# Create folder structure
@@ -127,43 +133,45 @@ Before running LUMExt-API, it is necessary to configure it.
127133

128134
```bash
129135
# Copy configuration sample
130-
cp config.sample.json $LUMEXT_CONFIGURATION_FILE_PATH
136+
cp config.sample.yaml $LUMEXT_CONFIGURATION_FILE_PATH
131137
# Copy log configuration (so you will be able to edit it for your purpose)
132138
cp logging.json $LUMEXT_HOME/etc
133139
```
134140

135-
Then you will need to edit the following line of the `/opt/sii/lumext/etc/config.json` file:
136-
137-
```json
138-
{
139-
"rabbitmq": {
140-
"server": "<address of rmq server>",
141-
"port": "<tcp port of rmq server>",
142-
"user": "<amqp username>",
143-
"password": "<amqp password>",
144-
"exchange": "<configured exchange on vCD>",
145-
"queue": "sii-lumext",
146-
"routing_key": "sii-lumext",
147-
"use_ssl": true // true/false depending on your rmq server
148-
},
149-
"ldap": {
150-
"address": "ldaps://---------:636", // ldap address starting with ldap:// or ldaps://
151-
"user": "user@domain", // username for LDAP administration
152-
"secret": "<ldap user password>",
153-
"base": "dc=domain,dc=tld", // LDAP base path to use as a root for OU creation(s)
154-
"domain": "domain.tld", // name of the LDAP domain
155-
"search_timeout": 5, // seconds
156-
"operation_timeout": 5, // seconds
157-
"cacert_file": "/etc/ssl/certs/ca-certificates.crt", // If LDAPs is used
158-
"userAccountControl": 66048 // Default mode for user creation (66048: no password expiration + user activated)
159-
},
160-
"log": {
161-
"config_path": "/opt/sii/lumext/etc/logging.json" // path to the log configuration file
162-
}
163-
}
141+
Then you will need to edit the following line of the `/opt/sii/lumext/etc/config.yaml` file:
142+
143+
```yaml
144+
rabbitmq:
145+
server: rmq.domain # address of rabbitmq server
146+
port: 5672 # tcp port of rabbitmq server
147+
user: svc-user # amqp username
148+
password: "**********" # amqp password
149+
exchange: systemExchange # configured exchange for vCD
150+
queue: sii-lumext
151+
routing_key: sii-lumext
152+
use_ssl: true # true/false depending on your rmq server
153+
154+
ldap:
155+
address: ldaps://---------:636 # ldap address starting with ldap:// or ldaps://
156+
user: user@domain # username for LDAP administration
157+
secret: "***********" # password for LDAP administration
158+
base: dc=domain,dc=tld # LDAP base path to use as a root for OU creation(s)
159+
domain: domain.tld # name of the LDAP domain
160+
search_timeout: 5 # seconds
161+
operation_timeout: 5 # seconds
162+
cacert_file: /etc/ssl/certs/ca-certificates.crt # If LDAPs is used
163+
userAccountControl: 66048 # Default mode for user creation:
164+
# - (66048: no password expiration + user activated)
165+
166+
log:
167+
config_path: /opt/sii/lumext/etc/logging.json
164168
```
165169
166-
> Remove all ``//.*`` comments as it it not supported in JSON syntax.
170+
> **Note about LDAPs certificates:**
171+
>
172+
> To use LDAPs, a *cacert* file is mandatory to validate the certificate submitted by the server. You can use a custom CA cert chain (*PEM format*) or, if you use a certificate signed by an OS-trusted CA, use the OS declaration of the trusted certificates.
173+
>
174+
> Please refer to [`Python-LDAP` library documentation](https://www.python-ldap.org/en/latest/index.html) for more details.
167175

168176
#### Test
169177

@@ -198,7 +206,7 @@ After="network-online.target"
198206
199207
[Service]
200208
Environment="LUMEXT_HOME=/opt/sii/lumext"
201-
Environment="LUMEXT_CONFIGURATION_FILE_PATH=/opt/sii/lumext/etc/config.json"
209+
Environment="LUMEXT_CONFIGURATION_FILE_PATH=/opt/sii/lumext/etc/config.yaml"
202210
WorkingDirectory=/opt/sii/lumext
203211
ExecStart=/opt/sii/lumext/lumext-venv/bin/python -m lumext_api
204212
Restart=on-failure

api/config.sample.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
rabbitmq:
2+
server: rmq.domain # address of rabbitmq server
3+
port: 5672 # tcp port of rabbitmq server
4+
user: svc-user # amqp username
5+
password: "**********" # amqp password
6+
exchange: systemExchange # configured exchange for vCD
7+
queue: sii-lumext
8+
routing_key: sii-lumext
9+
use_ssl: true # true/false depending on your rmq server
10+
11+
ldap:
12+
address: ldaps://---------:636 # ldap address starting with ldap:// or ldaps://
13+
user: user@domain # username for LDAP administration
14+
secret: "***********" # password for LDAP administration
15+
base: dc=domain,dc=tld # LDAP base path to use as a root for OU creation(s)
16+
domain: domain.tld # name of the LDAP domain
17+
search_timeout: 5 # seconds
18+
operation_timeout: 5 # seconds
19+
cacert_file: /etc/ssl/certs/ca-certificates.crt # If LDAPs is used
20+
userAccountControl: 66048 # Default mode for user creation:
21+
# - (66048: no password expiration + user activated)
22+
23+
log:
24+
config_path: /opt/sii/lumext/etc/logging.json

api/lumext_api/utils.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import os
88

99
# PIP imports
10-
import simplejson as json
11-
from python_json_config import ConfigBuilder
10+
import yaml
1211

1312
logger = logging.getLogger(__name__)
1413

@@ -80,15 +79,15 @@ def validate_configuration_path(env):
8079
print(f"""Missing environment variable `{env}`.
8180
8281
Please:
83-
1. copy the `config.sample.json` file to a new location.
82+
1. copy the `config.sample.yaml` file to a new location.
8483
2. Configure the copy with your settings.
8584
3. Export the environment variable `{env}`
8685
8786
Ex:
8887
```
8988
mkdir -p /opt/lumext/etc
90-
cp config.sample.json /opt/sii/lumext/etc/config.json
91-
export {env}=/opt/sii/lumext/etc/config.json
89+
cp config.sample.yaml /opt/sii/lumext/etc/config.yaml
90+
export {env}=/opt/sii/lumext/etc/config.yaml
9291
```
9392
""")
9493
sys.exit(-1)
@@ -100,14 +99,14 @@ def validate_configuration_path(env):
10099
correctly setted.
101100
""")
102101
sys.exit(-1)
103-
with open(config_path) as json_config:
102+
with open(config_path) as yaml_config:
104103
try:
105-
json.load(json_config)
106-
except json.errors.JSONDecodeError:
104+
yaml.load(yaml_config, Loader=yaml.SafeLoader)
105+
except yaml.scanner.ScannerError:
107106
print(f"""Invalid syntax in configuration file: {config_path}
108107
109108
Please check that the content of the configuration file is a
110-
valid JSON document.
109+
valid YAML document.
111110
""")
112111
sys.exit(-1)
113112
return
@@ -121,10 +120,11 @@ def configuration_manager():
121120
"""
122121
# Read config path from rnv settings.
123122
config_path = os.environ.get("LUMEXT_CONFIGURATION_FILE_PATH")
124-
# create config parser
125-
builder = ConfigBuilder()
123+
# load config file
124+
with open(config_path) as yaml_config:
125+
c = yaml.load(yaml_config, Loader=yaml.SafeLoader)
126126
# parse config
127-
return builder.parse_config(config_path)
127+
return dict2obj(c)
128128

129129

130130
def list_get(arr: list, index: int, default: any = None):
@@ -144,4 +144,27 @@ def list_get(arr: list, index: int, default: any = None):
144144
try:
145145
return arr[index]
146146
except IndexError:
147-
return default
147+
return default
148+
149+
150+
def dict2obj(d):
151+
"""Convert a dict to an object.
152+
153+
Args:
154+
d (dict): Dict to convert.
155+
156+
Returns:
157+
object: Converted object.
158+
"""
159+
if isinstance(d, list):
160+
d = [dict2obj(x) for x in d]
161+
if not isinstance(d, dict):
162+
return d
163+
164+
class C(object):
165+
pass
166+
167+
o = C()
168+
for k in d:
169+
o.__dict__[k] = dict2obj(d[k])
170+
return o

api/setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from distutils.core import setup
22
import setuptools
33

4-
with open("README.md", "r") as fh:
5-
long_description = fh.read()
4+
long_description = """LDAP user management extension for vCloud Director >=9.1
5+
6+
LUMext is a vCD UI & API extension to manage LDAP-based organisation's users and groups through *VMware vCloud Director*.
7+
8+
This extension aims to provide a way to share a single LDAP server for multiple organisations to simplify the user management.
9+
"""
610

711
setup(
812
name='lumext_api',
@@ -16,7 +20,7 @@
1620
install_requires=[
1721
"VcdExtMessageWorker",
1822
"coloredlogs",
19-
"python-json-config",
23+
"pyyaml",
2024
"python-ldap",
2125
"simplejson",
2226
],
File renamed without changes.
11.8 KB
Loading
486 Bytes
Loading

ui/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# LUMext UI
2+
3+
## Installation
4+
5+
See [README.md](../) of the main project.
6+
7+
## Build `plugin.zip`
8+
9+
To get `plugin.zip` you need to construct `/dist` folder
10+
11+
### What contains `/dist` folder ?
12+
13+
In `/dist` you will find all UI :
14+
15+
* folder `assets` with translations (empty in our case).
16+
* `bundle.js`: all the project UI translates in JavaScript.
17+
* `i18n.json`: translation of menu.
18+
* `manifest.json`: description of UI extension.
19+
* `plugin.zip`: ZIP of all previous files.
20+
21+
### Pre-requisites
22+
23+
* NodeJS
24+
* Yarn
25+
* A clone of the project
26+
27+
### Get dependencies
28+
29+
To Install all dependencies:
30+
31+
```bash
32+
yarn install
33+
```
34+
35+
### Build `/dist` with `plugin.zip`
36+
37+
Use yarn's build command
38+
39+
```bash
40+
yarn run build
41+
```
42+
43+
The `/dist` will be created automatically in the current folder with `plugin.zip` in.
44+
45+
### Full example of build process on Ubuntu
46+
47+
Clone the project:
48+
49+
```bash
50+
git clone https://github.com/groupe-sii/lumext.git lumext-app
51+
cd lumext-app/ui
52+
```
53+
54+
Install node and npm:
55+
56+
```bash
57+
sudo apt install nodejs npm curl
58+
```
59+
60+
Install Yarn:
61+
62+
```bash
63+
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
64+
sudo apt-get update && sudo apt-get install yarn
65+
```
66+
67+
Build dependencies (in the folder project):
68+
69+
```bash
70+
yarn install
71+
```
72+
73+
Build `/dist` with `plugin.zip`:
74+
75+
```bash
76+
yarn run build
77+
```

0 commit comments

Comments
 (0)