Authentication, Authorization and Accounting (AAA) is a term for a framework controlling access to resources, enforcing policies to use those resources and auditing their usage. These processes are the fundamental building blocks for effective network management and security.
Authentication provides a way of identifying a user, typically by having the user enter a valid user name and valid password before access is granted. The process of authentication is based on each user having a unique set of criteria for gaining access. The AAA framework compares a user’s authentication credentials with other user credentials stored in a database. If the credentials match, the user is granted access to the network. If the credentials don’t match, authentication fails and access is denied.
Authorization is the process of finding out what an authenticated user is allowed to do within the system, which tasks can do, which API can call, etc. The authorization process determines whether the user has the authority to perform such actions.
Accounting is the process of logging the activity of an authenticated user, for example, the amount of data a user has sent and/or received during a session, which APIs called, etc.
Get the code:
git clone https://git.opendaylight.org/gerrit/aaa
Build it:
cd aaa && mvn clean install
AAA is automatically installed upon installation of odl-restconf, but you can install it yourself directly from the Karaf console through the following command:
feature:install odl-aaa-shiro
The following are basic instructions to push your contributions to the project’s GIT repository:
git add .
git commit -s
# make changes, add change id, etc.
git commit --amend
git push ssh://{username}@git.opendaylight.org:29418/aaa.git HEAD:refs/for/master
Since Boron release, the OpenDaylight’s AAA services are based on the Apache Shiro Java Security Framework. The main configuration file for AAA is located at “etc/shiro.ini” relative to the OpenDaylight Karaf home directory.
The database (H2) used by ODL AAA Authentication store is not-cluster enabled. When deployed in a clustered environment each node needs to have its AAA user file synchronized using out of band means.
AAA is enabled through installing the odl-aaa-shiro feature. The vast majority of OpenDaylight’s northbound APIs (and all RESTCONF APIs) are protected by AAA by default when installing the +odl-restconf+ feature, since the odl-aaa-shiro is automatically installed as part of them.
Edit the “etc/shiro.ini” file and replace the following:
/** = authcBasic
with
/** = anon
Then, restart the Karaf process.
In order to provide security to a servlet, add the following to the servlet’s web.xml file as the first filter definition:
<context-param>
<param-name>shiroEnvironmentClass</param-name>
<param-value>org.opendaylight.aaa.shiro.web.env.KarafIniWebEnvironment</param-value>
</context-param>
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.opendaylight.aaa.shiro.filters.AAAShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AAAShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Note
It is very important to place this AAAShiroFilter as the first javax.servlet.Filter, as Jersey applies Filters in the order they appear within web.xml. Placing the AAAShiroFilter first ensures incoming HTTP/HTTPS requests have proper credentials before any other filtering is attempted.
AAA plugin utilizes the Shiro Realms to support pluggable authentication & authorization schemes. There are two parent types of realms:
OpenDaylight contains five implementations:
Note
More than one Realm implementation can be specified. Realms are attempted in order until authentication succeeds or all realm sources are exhausted. Edit the securityManager.realms = $tokenAuthRealm property in shiro.ini and add all the realms needed separated by commas.
The TokenAuthRealm is the default Authorization Realm deployed in OpenDaylight. TokenAuthRealm uses a direct authentication mechanism as shown in the following picture:
A user presents some credentials (e.g., username/password) directly to the OpenDaylight controller token endpoint /oauth2/token and receives an access token, which then can be used to access protected resources on the controller.
The H2 database provides an optional front-end Web interface, which can be very useful for new users. From the KARAF_HOME directory, you can run the following command to enable the user interface:
java -cp ./data/cache/org.eclipse.osgi/bundles/217/1/.cp/h2-1.4.185.jar
org.h2.tools.Server -trace -pg -web -webAllowOthers -baseDir `pwd`
You can navigate to the following and login via the browser:
http://{IP}:8082/
LDAP integration is provided in order to externalize identity management. This configuration allows federation with an external LDAP server. The user’s OpenDaylight role parameters are mapped to corresponding LDAP attributes as specified by the groupRolesMap. Thus, an LDAP operator can provision attributes for LDAP users that support different OpenDaylight role structures.
This is useful for setups where all LDAP users are allowed equal access.
This realm authenticates OpenDaylight users against the OpenStack’s Keystone server. This realm uses the Keystone’s Identity API v3 or later.
As can shown on the above diagram, once configured, all the RESTCONF APIs calls will require sending user, password and optionally domain (1). Those credentials are used to authenticate the call against the Keystone server (2) and, if the authentication succeeds, the call will proceed to the MDSAL (3). The credentials must be provisioned in advance within the Keystone Server. The user and password are mandatory, while the domain is optional, in case it is not provided within the REST call, the realm will default to (Default), which is hard-coded. The default domain can be also configured through the shiro.ini file (see the AAA User Guide).
The protocol between the Controller and the Keystone Server (2) can be either HTTPS or HTTP. In order to use HTTPS the Keystone Server’s certificate must be exported and imported on the Controller (see the Certificate Management section).
OpenDaylight supports two authorization engines at present, both of which are roughly similar in behavior:
Note
The preferred mechanism for configuring AAA Authentication is the MDSAL-Based Dynamic Authorization. Read the following section.
OpenDaylight AAA has support for Role Based Access Control (RBAC) based on the Apache Shiro permissions system. Configuration of the authorization system is done off-line; authorization currently cannot be configured after the controller is started. The Authorization provided by this mechanism is aimed towards supporting coarse-grained security policies, the MDSAL-Based mechanism allows for a more robust configuration capabilities. Shiro-based Authorization describes how to configure the Authentication feature in detail.
The MDSAL-Based Dynamic authorization uses the MDSALDynamicAuthorizationFilter engine to restrict access to particular URL endpoint patterns. Users may define a list of policies that are insertion-ordered. Order matters for that list of policies, since the first matching policy is applied. This choice was made to emulate behavior of the Shiro-Based Authorization mechanism.
A policy is a key/value pair, where the key is a resource (i.e., a “URL pattern”) and the value is a list of permissions for the resource. The following describes the various elements of a policy:
This an example on how to limit access to the modules endpoint:
HTTP Operation:
put URL: /restconf/config/aaa:http-authorization/policies
headers: Content-Type: application/json Accept: application/json
body:
{ "aaa:policies":
{ "aaa:policies":
[ { "aaa:resource": "/restconf/modules/**",
"aaa:permissions": [ { "aaa:role": "admin",
"aaa:actions": [ "get",
"post",
"put",
"patch",
"delete"
]
}
]
}
]
}
}
The above example locks down access to the modules endpoint (and any URLS available past modules) to the “admin” role. Thus, an attempt from the OOB admin user will succeed with 2XX HTTP status code, while an attempt from the OOB user user will fail with HTTP status code 401, as the user user is not granted the “admin” role.
Accounting is handled through the standard slf4j logging mechanisms used by the rest of OpenDaylight. Thus, one can control logging verbosity through manipulating the log levels for individual packages and classes directly through the Karaf console, JMX, or etc/org.ops4j.pax.logging.cfg. In normal operations, the default levels exposed do not provide much information about AAA services; this is due to the fact that logging can severely degrade performance.
All AAA logging is output to the standard karaf.log file. For debugging purposes (i.e., to enable maximum verbosity), issue the following command:
log:set TRACE org.opendaylight.aaa
By default, successful/unsuccessful authentication attempts are NOT logged. This is due to the fact that logging can severely decrease REST performance.
It is possible to add custom AuthenticationListener(s) to the Shiro-based configuration, allowing different ways to listen for successful/unsuccessful authentication attempts. Custom AuthenticationListener(s) must implement the org.apache.shiro.authc.AuthenticationListener interface.
The Certificate Management Service is used to manage the keystores and certificates at the OpenDaylight distribution to easily provides the TLS communication.
The Certificate Management Service managing two keystores:
The Certificate Management Service stores the keystores (OpenDaylight & Trust) as .jks files under configuration/ssl/ directory. Also the keystores could be stored at the MD-SAL datastore in case OpenDaylight distribution running at cluster environment. When the keystores are stored at MD-SAL, the Certificate Management Service rely on the Encryption-Service to encrypt the keystore data before storing it to MD-SAL and decrypted at runtime.
The following are the steps to configure the TLS communication within your feature or module:
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-cert</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
import org.opendaylight.aaa.cert.api.ICertificateManager;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
public class UseCertManagerExampleProvider {
private final DataBroker dataBroker;
private final ICertificateManager caManager;
public EncSrvExampleProvider(final DataBroker dataBroker, final ICertificateManager caManager) {
this.dataBroker = dataBroker;
this.caManager = caManager;
}
public SSLEngine createSSLEngine() {
final SSLContext sslContext = caManager.getServerContext();
if (sslContext != null) {
final SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setEnabledCipherSuites(caManager.getCipherSuites());
// DO the Implementation
return sslEngine;
}
}
public void init() {
// TODO
}
public void close() {
// TODO
}
}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default" />
<reference id="aaaCertificateManager"
interface="org.opendaylight.aaa.cert.api.ICertificateManager"
odl:type="default-certificate-manager" />
<bean id="provider"
class="org.opendaylight.UseCertManagerExample.impl.UseCertManagerExampleProvider"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
<argument ref="aaaCertificateManager" />
</bean>
</blueprint>
<properties>
<aaa.version>0.5.0-SNAPSHOT</aaa.version>
</properties>
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>features-aaa</artifactId>
<version>${aaa.version}</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
<repository>mvn:org.opendaylight.aaa/features-aaa/{VERSION}/xml/features</repository>
The Certificate Manager Service feature can be included inside the implementation bundle feature as shown in the following example:
<feature name='odl-UseCertManagerExample' version='${project.version}'
description='OpenDaylight :: UseCertManagerExample'>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${aaa.version}'>odl-aaa-cert</feature>
<bundle>mvn:org.opendaylight.UseCertManagerExample/UseCertManagerExample-impl/{VERSION}</bundle>
</feature>
The AAA Encryption Service is used to encrypt the OpenDaylight users’ passwords and TLS communication certificates. This section shows how to use the AAA Encryption Service with an OpenDaylight distribution project to encrypt data.
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-encrypt-service</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
public class EncSrvExampleProvider {
private final DataBroker dataBroker;
private final AAAEncryptionService encryService;
public EncSrvExampleProvider(final DataBroker dataBroker, final AAAEncryptionService encryService) {
this.dataBroker = dataBroker;
this.encryService = encryService;
}
public void init() {
// TODO
}
public void close() {
// TODO
}
}
The AAAEncryptionService can be used to encrypt and decrypt any data based on project’s needs.
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default" />
<reference id="encryService" interface="org.opendaylight.aaa.encrypt.AAAEncryptionService"/>
<bean id="provider"
class="org.opendaylight.EncSrvExample.impl.EncSrvExampleProvider"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
<argument ref="encryService" />
</bean>
</blueprint>
<dependency>
<groupId>org.opendaylight.aaa</groupId>
<artifactId>features-aaa</artifactId>
<version>${aaa.version}</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
It is also necessary to add the aaa.version in the properties section:
<properties>
<aaa.version>0.5.0-SNAPSHOT</aaa.version>
</properties>
<repository>mvn:org.opendaylight.aaa/features-aaa/{VERSION}/xml/features</repository>
The Encryption Service feature can be included inside the implementation bundle feature as shown in the following example:
<feature name='odl-EncSrvExample' version='${project.version}' description='OpenDaylight :: EncSrvExample'>
<feature version='${mdsal.version}'>odl-mdsal-broker</feature>
<feature version='${aaa.version}'>odl-aaa-encryption-service</feature>
<feature version='${project.version}'>odl-EncSrvExample-api</feature>
<bundle>mvn:org.opendaylight.EncSrvExample/EncSrvExample-impl/{VERSION}</bundle>
</feature>