SDC provides a set of external API's that are exposed from our side SDC API.
This API's are authenticated using basic authentication.
In order to integrate with other components, consumers are configured per component. This operation is performed as an integral part of executing the Backend Docker.
The following users are predefined:
- appc
- vid
- dcae
- aai
- sdnc
- mso
For the purposes of this document the manual consumer configuration process is described.
To create new SDC consumers:
you will need to compile our security utiles project, the project has a set of functionalities for hashing password using SHA-256.
clone the SDC project:
Code Block git clone http://gerrit.onap.org/r/a/sdc
- Under the cloned project go to security-utils.
Run:
Code Block mvn clean install
- This will generate a security-utils-<version>.jar under the target dir.
Executed the jar with the password you want to generate a hash for:
Code Block java -cp /tmp/security-utils-*.jar org.openecomp.sdc.security.Passwords password
- The jar will return the salt and the hash generated by adding the salt to the provided password before hashing it. the response format is <salt>:<hash>
- Now that we have the salt we need to create a consumer in SDC.
To create a consumer execute the following curl command towards the SDC backend server:
Code Block curl -X POST -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://<ip of the server you want to accses>:8080/sdc2/rest/v1/consumers/ -d '{"consumerName": '<consumer name>', "consumerSalt": '<salt>',"consumerPassword": '<hash>'}'
- The CURL creates the consumer in the SDC DB. from this moment you can access our external API's using the consumer name and the password used for the hash generation.
- the hash function is a one way so if you forget the password SDC will not be able to recreate it and you will need to delete the consumer and create a new one.
- This information should be added to the API call as a basic authentication header.
You can check if the created user exists by calling:
Code Block curl -X GET -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://localhost:8080/sdc2/rest/v1/consumers/<consumer name> HTTP/1.1 200 OK Set-Cookie: JSESSIONID=1ahpyqpjjgfblahos4f03qun9;Path=/ Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 X-ECOMP-RequestID: 6e47cbde-44e8-4b82-8f17-c6a731bf0081 Vary: Accept-Encoding, User-Agent Content-Length: 268 Server: Jetty(9.3.12.v20160915) {"consumerName":"<consumer name>","consumerPassword":"<counsumer hashed password>","consumerSalt":"eaa62d9681d8f803ac05db342e3c9cc0","consumerLastAuthenticationTime":0,"consumerDetailsLastupdatedtime":1481211500749,"lastModfierUserId":"jh0003"}
In Linux you can use this commands:
Run the following commands, providing consumer specific values for the parameters that are inside <>:
Code Block |
---|
consumerName=<Consumer user name> (For example: appc )
user_pass=<Consumer password> (For example: appcos )
IP=localhost <OR Docker IP>
enc_pass=`java -cp <jar locataion>/security-utils-*.jar org.openecomp.sdc.security.Passwords $user_pass |tr '[]' ' '|awk '{print $1}'`
salt=`echo $enc_pass |awk -F: '{print $1}'
pass=`echo $enc_pass |awk -F: '{print $2}'
curl -X POST -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://$IP:8080/sdc2/rest/v1/consumers/ -d '{"consumerName": '$consumerName', "consumerSalt": '$salt',"consumerPassword": '$pass'}'
|
Note |
---|
Note: Repeat the consumer creation process for each consumer, providing Consumer specificconsumerNameand user_pass |
...
Code Block |
---|
consumerName=appc
user_pass=appcos
enc_pass=`java -cp /tmp/security-utils-1702.0.11.jar org.openecomp.sdc.security.Passwords $user_pass |tr '[]' ' '|awk '{print $1}'`
salt=`echo $enc_pass |awk -F: '{print $1}'`
pass=`echo $enc_pass |awk -F: '{print $2}'`
curl -X POST -i -H "Accept: application/json; charset=UTF-8" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://localhost:8080/sdc2/rest/v1/consumers/ -d '{"consumerName": '$consumerName', "consumerSalt": '$salt',"consumerPassword": '$pass'}' |
Check that the consumer was successfully created in SDC:
...
Introduction
This option is for developers working locally on SDC.
SDC Simulator is a project that enables emulation of WEB server that provides security policy and sign-on to the SDC component in dev environments.
- Provides a sign on to the basic user roles/functionalities
- Creation of basic user accounts
Docker compilation - Docker Maven Build Profile (io.fabric8 maven Plugin)
If you are using ONAP-Vagrant environment you can deploy the simulator by:
Set up the DOCKER_HOST environmental variable
To set environmental variable in Windows (the docker engine environment):
- Run `cmd`
- Issue command `set NAME=VALUE`
Code Block |
---|
set DOCKER_HOST=tcp://192.168.50.5:2375 |
- To check if the variable set succeeded issue:
Code Block |
---|
echo %DOCKER_HOST% |
To compile sdc-simulator docker:
1. Run
Code Block |
---|
mvn clean install -pl utils/webseal-simulator -P docker |
2. Copy the script /sdc-chef-os/scripts/docker_run.sh to the docker engine environment and run:
Code Block | ||
---|---|---|
| ||
/data/scripts/docker_run.sh -l -d sdc-sim -sim |
Code Block | ||
---|---|---|
| ||
/data/scripts/docker_run.sh -r <docker tag> -d sdc-sim -sim |
3. To verify that sdc-simulator docker is up and running run:
Code Block |
---|
docker ps |
Make sure that a docker with id: sdc-simulator exists
4. Enter to UI: `http://<ip address>:8285/login`
Code Block |
---|
http://192.168.50.5:8285/login |
Docker compilation - Docker Engine
1. Build web simulator WAR file run in project “webseal simulator”:
Code Block |
---|
mvn clean install |
- This will generate war file (WSSimulator.war) in the target folder.
- Check that WSSimulator.war exists after first step No.1 in webseal-simulator/sdc-simulator folder.
2. Ftp war file: webseal-simulator/sdc-simulator folder to your localhost vagrant machine which runs docker engine daemon.
3. Run `docker build -t onap/sdc-simulator:1.1-STAGING-latest <PATH/sdc-simulator>`
Code Block |
---|
docker build -t onap/sdc-simulator:1.1-STAGING-latest /tmp/docker/sdc-simulator/ |
If running behind a proxy:
Code Block docker build --build-arg http_proxy=http://URL:PORT --build-arg https_proxy=http://URL:PORT -t openecomp/sdc-simulator:1.1-STAGING-latest /tmp/docker/sdc-simulator/
4. Validate that images pushed to the local repo by executing:
Code Block |
---|
docker images |
5. Copy the script /sdc-chef-os/scriptsdocker_run.sh to the docker engine environment, make it executable (chmod ugo+x) and run:
Code Block |
---|
/data/scripts/docker_run.sh -l -d sdc-sim -sim |
6.To verify that sdc-simulator docker is up and running execute:
Code Block |
---|
docker ps |
- If no docker sdc-simulator running execute `docker ps -a`
7. Enter to UI: http://<ip address>:8285/login
Code Block |
---|
http://localhost:8285/login |