This is simple demo application which uses Lighty with NETCONF Southbound plugin inside Spring Boot.
Application initializes OpenDaylight core components (MD-SAL, yangtools and controller) and NetConf Southbound plugin inside spring framework environment.
There is initialized fully functional md-sal inside the spring. The DataBroker is provided for SpringBoot dependency injection subsystem services and used in exposed REST endpoints. The REST endpoints provides very simple functionality for network-topology model inside global datastore.
Alongside the basic data broker, there is also integrated NETCONF Southbound plugin and some very basic NetConf functionality exposed through REST endpoints. The "lighty-toaster-device" was used as a NetConf device which uses toaster model from ODL repository.
This demo utilizes Spring's method security and jCasbin. Web layer injects spring SecurityContext so it is available for other beans in application.
- Authentication is handled by internal service
io.lighty.core.controller.springboot.services.UserAccessService
using internally stored uername / password credentials. - Authorization is handled by jCasbin library using RBAC model example in combination with Spring's Method Security.
This demo requires username / password access, following users are available
- userName="bob", password="secret", roles={ ROLE_USER, ROLE_ADMIN }
- userName="alice", password="secret", roles={ ROLE_USER }
mvn clean install
It is necessary to copy toaster@2009-11-20.yang file to $WORKING_DIR/cache/schema/toaster@2009-11-20.yang, to be possible to read NETCONF data from testing device (lighty-toaster-device).
mvn spring-boot:run
or
java -jar target/lighty-controller-springboot-22.0.0-SNAPSHOT.jar
or in any IDE, run main in
io.lighty.core.controller.springboot.MainApp
Protected data is accessible only after login. After login, each request must use same cookie JSESSIONID, because server is tracking http sessions by this cookie. When application has started, the REST endpoints are provided:
Login with username password, see Users available section. This request must be first one in order to use session cookie for consequent requests.
curl -i -X POST \
-c /tmp/lighty.cookies.txt \
-H "Content-Type:application/json" \
--data \
'{
"username": "bob",
"password": "secret"
}' \
"http://localhost:8888/services/security/login"
list all topology IDs stored in datastore
curl -i -b /tmp/lighty.cookies.txt \
-X GET "http://localhost:8888/services/data/topology/list"
create new topology with topology id "test-topology-id"
curl -i -b /tmp/lighty.cookies.txt \
-X PUT "http://localhost:8888/services/data/topology/id/test-topology-id"
delete existing topology with topology id "test-topology-id"
curl -i -b /tmp/lighty.cookies.txt \
-X DELETE "http://localhost:8888/services/data/topology/id/test-topology-id"
list all NETCONF devices with its connection status and "darknessFactor" data loaded from device (darknessFactor is contained in toaster model from ODL)
curl -i -b /tmp/lighty.cookies.txt \
-X GET "http://localhost:8888/services/data/netconf/list"
attempt to connect to device "test-device" with specific credentials and address:port
curl -i -X PUT \
-b /tmp/lighty.cookies.txt \
-H "Content-Type:application/json" \
--data \
'{
"username": "admin",
"password": "admin",
"address": "127.0.0.1",
"port": "17830"
}' \
"http://localhost:8888/services/data/netconf/id/test-device"
disconnect NETCONF device "test-device"
curl -i -b /tmp/lighty.cookies.txt \
-X DELETE "http://localhost:8888/services/data/netconf/id/test-device"
logout current https session
curl -i -b /tmp/lighty.cookies.txt \
-X GET "http://localhost:8888/services/security/logout"
- main Spring boot initializer class
- REST API for http session login / logout
- Lighty.io services initialization and beans definition for SpringBoot dependency injection system
- REST endpoints definition
- uses beans defined in class LightyConfiguration for modifying topologies in ODL md-sal
- REST endpoints definition for ODL NETCONF
- uses beans defined in class LightyConfiguration for connecting, disconnecting and listing NetConf devices
- Web filter performing Authentication, Authorization and integration with Spring security.