3.2. Datastore Access
The same access control rules apply to all datastores that support the NACM -- for example, the candidate configuration datastore or the running configuration datastore. All conventional configuration datastores and the operational state datastore are controlled by the NACM. Local files, remote files, or datastores accessed via the <url> parameter are not controlled by the NACM.3.2.1. Mapping New Datastores to NACM
It is possible that new datastores will be defined over time for use with NETCONF. The NACM MAY be applied to other datastores that have similar access rights as defined in the NACM. To apply the NACM to a new datastore, the new datastore specification needs to define how it maps to the NACM CRUDX (Create, Read, Update, Delete, eXec) access rights. It is possible that only a subset of the NACM access rights would be applicable. For example, only retrieval access control would be needed for a read-only datastore. Operations and access rights not supported by the NACM CRUDX model are outside the scope of this document. A datastore does not need to use the NACM, e.g., the datastore specification defines something else or does not use access control.3.2.2. Access Rights
A small set of hard-wired datastore access rights is needed to control access to all possible protocol operations, including vendor extensions to the standard protocol operation set. The CRUDX model can support all protocol operations: o Create: allows the client to add a new data node instance to a datastore. o Read: allows the client to read a data node instance from a datastore or receive the notification event type. o Update: allows the client to update an existing data node instance in a datastore. o Delete: allows the client to delete a data node instance from a datastore. o eXec: allows the client to execute the operation.
3.2.3. RESTCONF Methods
The RESTCONF protocol utilizes HTTP methods to perform datastore operations, similar to NETCONF. The NACM procedures were originally written for NETCONF protocol operations, so the RESTCONF methods are mapped to NETCONF operations for the purpose of access control processing. The enforcement procedures described within this document apply to both protocols unless explicitly stated otherwise. The request URI needs to be considered when processing RESTCONF requests on data resources: o For HEAD and GET requests, any data nodes that are ancestor nodes of the target resource are considered to be part of the retrieval request for access control purposes. o For PUT, PATCH, and DELETE requests, any data nodes that are ancestor nodes of the target resource are not considered to be part of the edit request for access control purposes. The access operation for these nodes is considered to be "none". The edit begins at the target resource. o For POST requests on data resources, any data nodes that are specified in the request URI, including the target resource, are not considered to be part of the edit request for access control purposes. The access operation for these nodes is considered to be "none". The edit begins at a child node of the target resource, specified in the message body.
Not all RESTCONF methods are subject to access control. The following table specifies how each method is mapped to NETCONF protocol operations. The value "none" indicates that the NACM is not applied at all to the specific RESTCONF method. +---------+-----------------+---------------------+-----------------+ | Method | Resource class | NETCONF operation | Access | | | | | operation | +---------+-----------------+---------------------+-----------------+ | OPTIONS | all | none | none | | HEAD | all | <get>, <get-config> | read | | GET | all | <get>, <get-config> | read | | POST | datastore, data | <edit-config> | create | | POST | operation | specified operation | execute | | PUT | data | <edit-config> | create, update | | PUT | datastore | <copy-config> | update | | PATCH | data, datastore | <edit-config> | update | | DELETE | data | <edit-config> | delete | +---------+-----------------+---------------------+-----------------+ Table 1: Mapping RESTCONF Methods to NETCONF3.2.4. <get> and <get-config> Operations
The NACM access rights are not directly coupled to the <get> and <get-config> protocol operations but apply to all <rpc> operations that would result in a "read" access operation to the target datastore. This section describes how these access rights apply to the specific access operations supported by the <get> and <get-config> protocol operations. Data nodes to which the client does not have read access are silently omitted, along with any descendants, from the <rpc-reply> message. This is done to allow NETCONF filters for <get> and <get-config> to function properly, instead of causing an "access-denied" error because the filter criteria would otherwise include unauthorized read access to some data nodes. For NETCONF filtering purposes, the selection criteria are applied to the subset of nodes that the user is authorized to read, not the entire datastore.3.2.5. <edit-config> Operation
The NACM access rights are not directly coupled to the <edit-config> "operation" attribute, although they are similar. Instead, a NACM access right applies to all protocol operations that would result in a particular access operation to the target datastore. This section describes how these access rights apply to the specific access operations supported by the <edit-config> protocol operation.
If the effective access operation is "none" (i.e., default-operation="none") for a particular data node, then no access control is applied to that data node. This is required to allow access to a subtree within a larger data structure. For example, a user may be authorized to create a new "/interfaces/interface" list entry but not be authorized to create or delete its parent container ("/interfaces"). If the "/interfaces" container already exists in the target datastore, then the effective operation will be "none" for the "/interfaces" node if an "/interfaces/interface" list entry is edited. If the protocol operation would result in the creation of a datastore node and the user does not have "create" access permission for that node, the protocol operation is rejected with an "access-denied" error. If the protocol operation would result in the deletion of a datastore node and the user does not have "delete" access permission for that node, the protocol operation is rejected with an "access-denied" error. If the protocol operation would result in the modification of a datastore node and the user does not have "update" access permission for that node, the protocol operation is rejected with an "access-denied" error. A "merge" or "replace" <edit-config> operation may include data nodes that do not alter portions of the existing datastore. For example, a container or list node may be present for naming purposes but does not actually alter the corresponding datastore node. These unaltered data nodes are ignored by the server and do not require any access rights by the client. A "merge" <edit-config> operation may include data nodes but not include particular child data nodes that are present in the datastore. These missing data nodes within the scope of a "merge" <edit-config> operation are ignored by the server and do not require any access rights by the client. The contents of specific restricted datastore nodes MUST NOT be exposed in any <rpc-error> elements within the reply. An <edit-config> operation may cause data nodes to be implicitly created or deleted as an implicit side effect of a requested operation. For example, a YANG when-stmt expression may evaluate to a different result, causing data nodes to be deleted, or created with default values; or if a data node is created under one branch of a YANG choice-stmt, then all data nodes under the other branches are
implicitly removed. No NACM access rights are required on any data nodes that are implicitly changed as a side effect of another allowed operation.3.2.6. <copy-config> Operation
Access control for the <copy-config> protocol operation requires special consideration because the administrator may be replacing the entire target datastore. If the source of the <copy-config> protocol operation is the running configuration datastore and the target is the startup configuration datastore, the client is only required to have permission to execute the <copy-config> protocol operation. Otherwise: o If the source of the <copy-config> operation is a datastore, then data nodes to which the client does not have read access are silently omitted. o If the target of the <copy-config> operation is a datastore, the client needs access to the modified nodes. Specifically: * If the protocol operation would result in the creation of a datastore node and the user does not have "create" access permission for that node, the protocol operation is rejected with an "access-denied" error. * If the protocol operation would result in the deletion of a datastore node and the user does not have "delete" access permission for that node, the protocol operation is rejected with an "access-denied" error. * If the protocol operation would result in the modification of a datastore node and the user does not have "update" access permission for that node, the protocol operation is rejected with an "access-denied" error.3.2.7. <delete-config> Operation
Access to the <delete-config> protocol operation is denied by default. The "exec-default" leaf does not apply to this protocol operation. Access control rules must be explicitly configured to allow invocation by a non-recovery session.
3.2.8. <commit> Operation
The server MUST determine the exact nodes in the running configuration datastore that are actually different and only check "create", "update", and "delete" access permissions for this set of nodes, which could be empty. For example, if a session can read the entire datastore but only change one leaf, that session needs to be able to edit and commit that one leaf.3.2.9. <discard-changes> Operation
The client is only required to have permission to execute the <discard-changes> protocol operation. No datastore permissions are needed.3.2.10. <kill-session> Operation
The <kill-session> operation does not directly alter a datastore. However, it allows one session to disrupt another session that is editing a datastore. Access to the <kill-session> protocol operation is denied by default. The "exec-default" leaf does not apply to this protocol operation. Access control rules must be explicitly configured to allow invocation by a non-recovery session.3.3. Model Components
This section defines the conceptual components related to the access control model.3.3.1. Users
A "user" is the conceptual entity that is associated with the access permissions granted to a particular session. A user is identified by a string that is unique within the server. As described in [RFC6241], the username string is derived from the transport layer during session establishment. If the transport layer cannot authenticate the user, the session is terminated.
3.3.2. Groups
Access to a specific NETCONF protocol operation is granted to a session. The session is associated with a group (i.e., not with a user). A group is identified by its name. All group names are unique within the server. Access control is applied at the level of groups. A group contains zero or more group members. A group member is identified by a username string. The same user can be a member of multiple groups.3.3.3. Emergency Recovery Session
The server MAY support a recovery session mechanism, which will bypass all access control enforcement. This is useful for restricting initial access and repairing a broken access control configuration.3.3.4. Global Enforcement Controls
There are five global controls that are used to help control how access control is enforced.3.3.4.1. enable-nacm Switch
A global "enable-nacm" on/off switch is provided to enable or disable all access control enforcement. When this global switch is set to "true", all requests are checked against the access control rules and only permitted if configured to allow the specific access request. When this global switch is set to "false", all access requests are permitted.3.3.4.2. read-default Switch
An on/off "read-default" switch is provided to enable or disable default access to receive data in replies and notifications. When the "enable-nacm" global switch is set to "true", this global switch is relevant if no matching access control rule is found to explicitly permit or deny read access to the requested datastore data or notification event type.
When this global switch is set to "permit" and no matching access control rule is found for the datastore read or notification event requested, access is permitted. When this global switch is set to "deny" and no matching access control rule is found for the datastore read or notification event requested, access is denied. This means that the requested data is not sent to the client. See step 11 in Section 3.4.5 for details.3.3.4.3. write-default Switch
An on/off "write-default" switch is provided to enable or disable default access to alter configuration data. When the "enable-nacm" global switch is set to "true", this global switch is relevant if no matching access control rule is found to explicitly permit or deny write access to the requested datastore data. When this global switch is set to "permit" and no matching access control rule is found for the datastore write requested, access is permitted. When this global switch is set to "deny" and no matching access control rule is found for the datastore write requested, access is denied. See step 12 in Section 3.4.5 for details.3.3.4.4. exec-default Switch
An on/off "exec-default" switch is provided to enable or disable default access to execute protocol operations. When the "enable-nacm" global switch is set to "true", this global switch is relevant if no matching access control rule is found to explicitly permit or deny access to the requested NETCONF protocol operation. When this global switch is set to "permit" and no matching access control rule is found for the NETCONF protocol operation requested, access is permitted. When this global switch is set to "deny" and no matching access control rule is found for the NETCONF protocol operation requested, access is denied. See step 12 in Section 3.4.4 and step 13 in Section 3.4.5 for details.
3.3.4.5. enable-external-groups Switch
When this global switch is set to "true", the group names reported by the transport layer for a session are used together with the locally configured group names to determine the access control rules for the session. When this switch is set to "false", the group names reported by the transport layer are ignored by the NACM.3.3.5. Access Control Rules
There are four types of rules available in the NACM: module rule: controls access for definitions in a specific YANG module, identified by its name. protocol operation rule: controls access for a specific protocol operation, identified by its YANG module and name. data node rule: controls access for a specific data node and its descendants, identified by its path location within the conceptual XML document for the data node. notification rule: controls access for a specific notification event type, identified by its YANG module and name.3.4. Access Control Enforcement Procedures
There are six separate phases that need to be addressed, four of which are related to the NETCONF message processing model (Section 3.1.3): 1. Initial operation 2. Session establishment 3. "access-denied" error handling 4. Incoming RPC message validation 5. Data node access validation 6. Outgoing <notification> authorization In addition, the initial startup mode for a NETCONF server, session establishment, and "access-denied" error-handling procedures also need to be considered.
The server MUST use the access control rules in effect at the time it starts processing the message. The same access control rules MUST stay in effect for the processing of the entire message.3.4.1. Initial Operation
Upon the very first startup of the NETCONF server, the access control configuration will probably not be present. If it isn't, a server MUST NOT allow any write access to any session role except a recovery session. Access rules are enforced any time a request is initiated from a user session. Access control is not enforced for server-initiated access requests, such as the initial load of the running configuration datastore, during bootup.3.4.2. Session Establishment
The access control model applies specifically to the well-formed XML content transferred between a client and a server after session establishment has been completed and after the <hello> exchange has been successfully completed. Once session establishment is completed and a user has been authenticated, the transport layer reports the username and a possibly empty set of group names associated with the user to the NETCONF server. The NETCONF server will enforce the access control rules, based on the supplied username, group names, and the configuration data stored on the server.3.4.3. "access-denied" Error Handling
The "access-denied" error-tag is generated when the access control system denies access to either a request to invoke a protocol operation or a request to perform a particular access operation on the configuration datastore. A server MUST NOT include any information the client is not allowed to read in any <error-info> elements within the <rpc-error> response.
3.4.4. Incoming RPC Message Validation
The diagram below shows the basic conceptual structure of the access control processing model for incoming NETCONF <rpc> messages within a server. NETCONF server +------------+ | XML | | message | | dispatcher | +------------+ | | V +---------------+ | <rpc> message | +---------------+ | | | | | +--------------------------------+ | +---------------+ | V V V +------------------+ +--------------------+ +--------------------+ | vendor operation | | standard operation | | standard operation | | <my-edit> | | <edit-config> | | <unlock> | +------------------+ +--------------------+ +--------------------+ | | | | V V +----------------------+ | configuration | | datastore | +----------------------+ Figure 3 Access control begins with the message dispatcher. After the server validates the <rpc> element and determines the namespace URI and the element name of the protocol operation being requested, the server verifies that the user is authorized to invoke the protocol operation.
The server MUST separately authorize every protocol operation by following these steps: 1. If the "enable-nacm" leaf is set to "false", then the protocol operation is permitted. 2. If the requesting session is identified as a recovery session, then the protocol operation is permitted. 3. If the requested operation is the NETCONF <close-session> protocol operation, then the protocol operation is permitted. 4. Check all the "group" entries to see if any of them contain a "user-name" entry that equals the username for the session making the request. If the "enable-external-groups" leaf is "true", add to these groups the set of groups provided by the transport layer. 5. If no groups are found, continue with step 10. 6. Process all rule-list entries, in the order they appear in the configuration. If a rule-list's "group" leaf-list does not match any of the user's groups, proceed to the next rule-list entry. 7. For each rule-list entry found, process all rules, in order, until a rule that matches the requested access operation is found. A rule matches if all of the following criteria are met: * The rule's "module-name" leaf is "*" or equals the name of the YANG module where the protocol operation is defined. * Either (1) the rule does not have a "rule-type" defined or (2) the "rule-type" is "protocol-operation" and the "rpc-name" is "*" or equals the name of the requested protocol operation. * The rule's "access-operations" leaf has the "exec" bit set or has the special value "*". 8. If a matching rule is found, then the "action" leaf is checked. If it is equal to "permit", then the protocol operation is permitted; otherwise, it is denied. 9. At this point, no matching rule was found in any rule-list entry.
10. If the requested protocol operation is defined in a YANG module advertised in the server capabilities and the "rpc" statement contains a "nacm:default-deny-all" statement, then the protocol operation is denied. 11. If the requested protocol operation is the NETCONF <kill-session> or <delete-config>, then the protocol operation is denied. 12. If the "exec-default" leaf is set to "permit", then permit the protocol operation; otherwise, deny the request. If the user is not authorized to invoke the protocol operation, then an <rpc-error> is generated with the following information: error-tag: access-denied error-path: Identifies the requested protocol operation. The following example represents the <edit-config> protocol operation in the NETCONF base namespace: <error-path xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> /nc:rpc/nc:edit-config </error-path> If a datastore is accessed, either directly or as a side effect of the protocol operation, then the server MUST intercept the access operation and make sure that the user is authorized to perform the requested access operation on the specified data, as defined in Section 3.4.5.3.4.5. Data Node Access Validation
If (1) a data node within a datastore is accessed or (2) an action or notification is tied to a data node, then the server MUST ensure that the user is authorized to perform the requested "read", "create", "update", "delete", or "execute" access operation on the specified data node. If an action is requested to be executed, the server MUST ensure that the user is authorized to perform the "execute" access operation on the requested action. If a notification tied to a data node is generated, the server MUST ensure that the user is authorized to perform the "read" access operation on the requested notification.
The data node access request is authorized by following these steps: 1. If the "enable-nacm" leaf is set to "false", then the access operation is permitted. 2. If the requesting session is identified as a recovery session, then the access operation is permitted. 3. Check all the "group" entries to see if any of them contain a "user-name" entry that equals the username for the session making the request. If the "enable-external-groups" leaf is "true", add to these groups the set of groups provided by the transport layer. 4. If no groups are found, continue with step 9. 5. Process all rule-list entries, in the order they appear in the configuration. If a rule-list's "group" leaf-list does not match any of the user's groups, proceed to the next rule-list entry. 6. For each rule-list entry found, process all rules, in order, until a rule that matches the requested access operation is found. A rule matches if all of the following criteria are met: * The rule's "module-name" leaf is "*" or equals the name of the YANG module where the requested data node is defined. * Either (1) the rule does not have a "rule-type" defined or (2) the "rule-type" is "data-node" and the "path" matches the requested data node, action node, or notification node. A path is considered to match if the requested node is the node specified by the path or is a descendant node of the path. * For a "read" access operation, the rule's "access-operations" leaf has the "read" bit set or has the special value "*". * For a "create" access operation, the rule's "access-operations" leaf has the "create" bit set or has the special value "*". * For a "delete" access operation, the rule's "access-operations" leaf has the "delete" bit set or has the special value "*".
* For an "update" access operation, the rule's "access-operations" leaf has the "update" bit set or has the special value "*". * For an "execute" access operation, the rule's "access-operations" leaf has the "exec" bit set or has the special value "*". 7. If a matching rule is found, then the "action" leaf is checked. If it is equal to "permit", then the data node access is permitted; otherwise, it is denied. For a "read" access operation, "denied" means that the requested data is not returned in the reply. 8. At this point, no matching rule was found in any rule-list entry. 9. For a "read" access operation, if the requested data node is defined in a YANG module advertised in the server capabilities and the data definition statement contains a "nacm:default-deny-all" statement, then the requested data node and all its descendants are not included in the reply. 10. For a "write" access operation, if the requested data node is defined in a YANG module advertised in the server capabilities and the data definition statement contains a "nacm:default-deny-write" or a "nacm:default-deny-all" statement, then the access request is denied for the data node and all its descendants. 11. For a "read" access operation, if the "read-default" leaf is set to "permit", then include the requested data node in the reply; otherwise, do not include the requested data node or any of its descendants in the reply. 12. For a "write" access operation, if the "write-default" leaf is set to "permit", then permit the data node access request; otherwise, deny the request. 13. For an "execute" access operation, if the "exec-default" leaf is set to "permit", then permit the request; otherwise, deny the request.
3.4.6. Outgoing <notification> Authorization
Configuration of access control rules specifically for descendant nodes of the notification event type are outside the scope of this document. If the user is authorized to receive the notification event type, then it is also authorized to receive any data it contains. If the notification is specified within a data subtree, as specified in [RFC7950], then read access to the notification is required. Processing continues as described in Section 3.4.5. The following figure shows the conceptual message processing model for outgoing <notification> messages. NETCONF server +------------+ | XML | | message | | generator | +------------+ ^ | +----------------+ | <notification> | | generator | +----------------+ ^ | +=================+ | <notification> | | access control | | <eventType> | +=================+ ^ | +------------------------+ | server instrumentation | +------------------------+ | ^ V | +----------------------+ | configuration | | datastore | +----------------------+ Figure 4
The generation of a notification for a specific subscription [RFC5277] is authorized by following these steps: 1. If the "enable-nacm" leaf is set to "false", then the notification is permitted. 2. If the session is identified as a recovery session, then the notification is permitted. 3. If the notification is the NETCONF <replayComplete> or <notificationComplete> event type [RFC5277], then the notification is permitted. 4. Check all the "group" entries to see if any of them contain a "user-name" entry that equals the username for the session making the request. If the "enable-external-groups" leaf is "true", add to these groups the set of groups provided by the transport layer. 5. If no groups are found, continue with step 10. 6. Process all rule-list entries, in the order they appear in the configuration. If a rule-list's "group" leaf-list does not match any of the user's groups, proceed to the next rule-list entry. 7. For each rule-list entry found, process all rules, in order, until a rule that matches the requested access operation is found. A rule matches if all of the following criteria are met: * The rule's "module-name" leaf is "*" or equals the name of the YANG module where the notification is defined. * Either (1) the rule does not have a "rule-type" defined or (2) the "rule-type" is "notification" and the "notification-name" is "*" or equals the name of the notification. * The rule's "access-operations" leaf has the "read" bit set or has the special value "*". 8. If a matching rule is found, then the "action" leaf is checked. If it is equal to "permit", then permit the notification; otherwise, drop the notification for the associated subscription. 9. Otherwise, no matching rule was found in any rule-list entry.
10. If the requested notification is defined in a YANG module advertised in the server capabilities and the "notification" statement contains a "nacm:default-deny-all" statement, then the notification is dropped for the associated subscription. 11. If the "read-default" leaf is set to "permit", then permit the notification; otherwise, drop the notification for the associated subscription.