<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs">Named ACLs</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~jrose">Jonathan Rose</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Added a use case for consumers simply retrieving named ACLs without verifying specific addresses at the time of use.<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* Consumers are notified that the Named ACL subsystem was updated. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3. Consumer of ACLs is loading and requests a named ACL <br> <br>h5. Actors <br> <br>* Named ACL Subsystem <br>* A single Consumer <br> <br>h5. Preconditions <br> <br>* A loaded and configured named ACL subsystem <br> <br>h5. Scenario - named ACL exists <br> <br># The consumer requests the ACL with the given name from the named ACL Subsystem <br># The consumer receives a copy of the requested ACL <br> <br>h5. Scenario - named ACL does not exist in Named ACL Subsystem <br> <br># The consumer requests the ACL with the given name from the named ACL Subsystem <br># The consumer is unable to obtain ACL information for that named ACL from the named ACL subsystem <br># The consumer warns the system of a configuration error. Any use of the ACL will result in rejection. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Consumer asks for named ACL information <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        

<h1><a name="NamedACLs-Overview"></a>Overview</h1>

<p>The primary goal for Named ACLs (Access Control Lists) is to provide users with a way to create commonly used ACL profiles and to be able to use those profiles wherever ACLs are consumed without the need to duplicate the list each time it is used (often with varying keywords for defining the ACLs). This will make the creation and maintainence of complex ACLs an easier, less error prone process. An implementation of this concept exists within a team branch written by Olle E. Johansson.</p>

<h1><a name="NamedACLs-TableofContents"></a>Table of Contents</h1>

<style type='text/css'>/*<![CDATA[*/
div.rbtoc1341345375233 {margin-left: 1.5em;padding: 0px;}
div.rbtoc1341345375233 ul {list-style: disc;margin-left: 0px;padding-left: 20px;}
div.rbtoc1341345375233 li {margin-left: 0px;padding-left: 0px;}

/*]]>*/</style><div class='rbtoc1341345375233'>
<ul>
    <li><a href='#NamedACLs-Overview'>Overview</a></li>
    <li><a href='#NamedACLs-TableofContents'>Table of Contents</a></li>
    <li><a href='#NamedACLs-UseCasesInitialImplementation'>Use Cases - Initial Implementation</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-NamedACLandConsumersModuleLoad'>Named ACL and Consumers - Module Load</a></li>
<ul>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-Scenario'>Scenario</a></li>
    <li><a href='#NamedACLs-PostConditions'>Post Conditions</a></li>
</ul>
    <li><a href='#NamedACLs-NamedACLReload'>Named ACL - Reload</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-Scenario'>Scenario</a></li>
    <li><a href='#NamedACLs-Postconditions'>Postconditions</a></li>
</ul>
    <li><a href='#NamedACLs-ConsumerofACLsisloadingandrequestsanamedACL'>Consumer of ACLs is loading and requests a named ACL</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-ScenarionamedACLexists'>Scenario - named ACL exists</a></li>
    <li><a href='#NamedACLs-ScenarionamedACLdoesnotexistinNamedACLSubsystem'>Scenario - named ACL does not exist in Named ACL Subsystem</a></li>
</ul>
    <li><a href='#NamedACLs-ConsumerasksfornamedACLinformation'>Consumer asks for named ACL information</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-ScenarionamedACLexists'>Scenario - named ACL exists</a></li>
    <li><a href='#NamedACLs-ScenarionamedACLdoesnotexistinNamedACLSubsystem'>Scenario - named ACL does not exist in Named ACL Subsystem</a></li>
</ul>
</ul>
</ul>
    <li><a href='#NamedACLs-UseCasesDynamicNamedACLUpdating'>Use Cases - Dynamic Named ACL Updating</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
<ul>
    <li><a href='#NamedACLs-InitiatorupdatesanamedACL'>Initiator updates a named ACL</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-Scenario'>Scenario</a></li>
    <li><a href='#NamedACLs-Postconditions'>Postconditions</a></li>
</ul>
    <li><a href='#NamedACLs-ConsumerupdatesanamedACL'>Consumer updates a named ACL</a></li>
<ul>
    <li><a href='#NamedACLs-Actors'>Actors</a></li>
    <li><a href='#NamedACLs-Preconditions'>Preconditions</a></li>
    <li><a href='#NamedACLs-ScenarioAddorUpdateAccepted'>Scenario - Add or Update Accepted</a></li>
    <li><a href='#NamedACLs-Postconditions'>Postconditions</a></li>
    <li><a href='#NamedACLs-ScenarioAddorUpdateRejected'>Scenario - Add or Update Rejected</a></li>
    <li><a href='#NamedACLs-Postconditions'>Postconditions</a></li>
</ul>
</ul>
</ul>
    <li><a href='#NamedACLs-Design'>Design</a></li>
<ul>
    <li><a href='#NamedACLs-NamedACLsubsystem'>Named ACL subsystem</a></li>
    <li><a href='#NamedACLs-ACLConsumerUsage'>ACL Consumer Usage</a></li>
<ul>
    <li><a href='#NamedACLs-astaclstructure'>ast_acl structure</a></li>
</ul>
</ul>
</ul></div>

<h1><a name="NamedACLs-UseCasesInitialImplementation"></a>Use Cases - Initial Implementation</h1>

<p>These use cases define the behavior of the Named ACL feature with respect to the initial implementation put up for review here:</p>

<p><a href="https://reviewboard.asterisk.org/r/1978/" class="external-link" rel="nofollow">https://reviewboard.asterisk.org/r/1978/</a></p>

<h2><a name="NamedACLs-Actors"></a>Actors</h2>

<ul>
        <li>Named ACL Subsystem - the ACL subsystem that owns the definition of the named ACLs.  Currently, this is acl.c.</li>
        <li>Consumers - subsystems that use named ACLs to make internal decisions, e.g., chan_sip.</li>
</ul>


<p>Note that the configuration information for these actors could come from a variety of sources, such as .conf files, RealTime backends, etc.</p>

<h2><a name="NamedACLs-NamedACLandConsumersModuleLoad"></a>Named ACL and Consumers - Module Load</h2>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Named ACL Subsystem.</li>
        <li>One or more Consumers.</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>Configuration exists for all actors.</li>
</ul>


<h5><a name="NamedACLs-Scenario"></a>Scenario</h5>

<ol>
        <li>The Named ACL Subsystem is initialized.</li>
        <li>The Named ACL Subsystem loads configuration information.</li>
        <li>Each category in the configuration specifies a unique named ACL.  Key/value pairs within that category define the rules for that ACL.</li>
        <li>A Consumer is initialized (from here, steps are repeated for each consumer).</li>
        <li>The Consumer loads its configuration information.</li>
        <li>The Consumer's configuration specifies the usage of a named ACL defined by the Named ACL Subsystem.</li>
        <li>The Consumer has the ability to verify whether or not the named ACL key is valid.</li>
</ol>


<h5><a name="NamedACLs-PostConditions"></a>Post Conditions</h5>

<ul>
        <li>The Consumers have a key by which they can determine whether or not an address is allowable by that named ACL.</li>
</ul>


<h3><a name="NamedACLs-NamedACLReload"></a>Named ACL - Reload</h3>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Named ACL Subsystem.</li>
        <li>User or AMI connection.</li>
        <li>Consumers</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>Updated configuration exists for the Named ACL Subsystem.</li>
</ul>


<h5><a name="NamedACLs-Scenario"></a>Scenario</h5>

<ol>
        <li>The User or an AMI connection initiates a reload operation on the Named ACL Subsystem.</li>
        <li>The Named ACL subsystem reloads configuration information from its configuration.</li>
        <li>Atomically, the ACL subsystem replaces its named ACLs with those from its updated configuration.</li>
        <li>The Named ACL Subsystem notifies Consumers that its configuration was updated.</li>
</ol>


<h5><a name="NamedACLs-Postconditions"></a>Postconditions</h5>

<ul>
        <li>The Named ACL subsystem is reloaded with an updated configuration.</li>
        <li>Consumers are notified that the Named ACL subsystem was updated.</li>
</ul>


<h3><a name="NamedACLs-ConsumerofACLsisloadingandrequestsanamedACL"></a>Consumer of ACLs is loading and requests a named ACL</h3>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Named ACL Subsystem</li>
        <li>A single Consumer</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>A loaded and configured named ACL subsystem</li>
</ul>


<h5><a name="NamedACLs-ScenarionamedACLexists"></a>Scenario - named ACL exists</h5>

<ol>
        <li>The consumer requests the ACL with the given name from the named ACL Subsystem</li>
        <li>The consumer receives a copy of the requested ACL</li>
</ol>


<h5><a name="NamedACLs-ScenarionamedACLdoesnotexistinNamedACLSubsystem"></a>Scenario - named ACL does not exist in Named ACL Subsystem</h5>

<ol>
        <li>The consumer requests the ACL with the given name from the named ACL Subsystem</li>
        <li>The consumer is unable to obtain ACL information for that named ACL from the named ACL subsystem</li>
        <li>The consumer warns the system of a configuration error. Any use of the ACL will result in rejection.</li>
</ol>


<h3><a name="NamedACLs-ConsumerasksfornamedACLinformation"></a>Consumer asks for named ACL information</h3>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Named ACL Subsystem.</li>
        <li>A single Consumer.</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>A loaded and configured Named ACL Subsystem and Consumer.</li>
</ul>


<h5><a name="NamedACLs-ScenarionamedACLexists"></a>Scenario - named ACL exists</h5>

<ol>
        <li>The Consumer receives an address that it must verify against a named ACL.</li>
        <li>The Consumer verifies the address using the named ACL information from the Named ACL Subsystem.</li>
</ol>


<h5><a name="NamedACLs-ScenarionamedACLdoesnotexistinNamedACLSubsystem"></a>Scenario - named ACL does not exist in Named ACL Subsystem</h5>

<ol>
        <li>The Consumer receives an address that it must verify against a named ACL.</li>
        <li>The Consumer is unable to obtain ACL information for that named ACL from the Named ACL Subsystem.</li>
        <li>The Consumer warns the system (and relevant security frameworks) of a configuration error.</li>
</ol>


<h1><a name="NamedACLs-UseCasesDynamicNamedACLUpdating"></a>Use Cases - Dynamic Named ACL Updating</h1>

<p>These Use Cases define the behavior specified in Olle's pinequeue branch:</p>

<p><a href="http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-trunk/README.nacl?revision=242040" class="external-link" rel="nofollow">Pinequeue README</a></p>


<h2><a name="NamedACLs-Actors"></a>Actors</h2>

<p>In addition to the previously defined actors, the following are also present in these use cases.</p>

<ul>
        <li>Initiator - either a user initiating an update via a CLI command, a third party via an AMI connection, or some other external mechanism</li>
</ul>


<h3><a name="NamedACLs-InitiatorupdatesanamedACL"></a>Initiator updates a named ACL</h3>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Initiator.</li>
        <li>Named ACL Subsystem.</li>
        <li>Consumers.</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>A loaded and configured Named ACL Subsystem and Consumer.</li>
</ul>


<h5><a name="NamedACLs-Scenario"></a>Scenario</h5>

<ol>
        <li>Initiator provides information that adds or modified an existing named ACL.</li>
        <li>Named ACL Subsystem updates its information.</li>
        <li>Named ACL Subsystem updates its backing storage.</li>
        <li>The Named ACL Subsystem notifies Consumers that its configuration was updated.</li>
        <li>Consumer's named ACL information is modified based on the update.</li>
</ol>


<h5><a name="NamedACLs-Postconditions"></a>Postconditions</h5>

<ul>
        <li>The Named ACL subsystem is updated with the new named ACL information.</li>
        <li>Consumers are notified that the Named ACL subsystem was updated.</li>
        <li>Consumer's named ACL information is changed to reflect the update.</li>
</ul>


<h3><a name="NamedACLs-ConsumerupdatesanamedACL"></a>Consumer updates a named ACL</h3>

<h5><a name="NamedACLs-Actors"></a>Actors</h5>

<ul>
        <li>Named ACL Subsystem.</li>
        <li>Consumers.</li>
</ul>


<h5><a name="NamedACLs-Preconditions"></a>Preconditions</h5>

<ul>
        <li>A loaded and configured Named ACL Subsystem and Consumer.</li>
        <li>A Consumer has received information that a named ACL should be added or modified.</li>
</ul>


<h5><a name="NamedACLs-ScenarioAddorUpdateAccepted"></a>Scenario - Add or Update Accepted</h5>

<ol>
        <li>Consumer requests that a named ACL be added or updated with the appropriate information.</li>
        <li>Named ACL Subsystem determines that the ACL can be added or updated.</li>
        <li>Named ACL Subsystem updates its information.</li>
        <li>Named ACL Subsystem updates its backing storage.</li>
        <li>The Named ACL Subsystem notifies Consumers that its configuration was updated.</li>
        <li>Consumer's named ACL information is modified based on the update.</li>
</ol>


<h5><a name="NamedACLs-Postconditions"></a>Postconditions</h5>

<ul>
        <li>The Named ACL subsystem is updated with the new named ACL information.</li>
        <li>Consumers are notified that the Named ACL subsystem was updated.</li>
        <li>Consumer's named ACL information is changed to reflect the update.</li>
</ul>


<h5><a name="NamedACLs-ScenarioAddorUpdateRejected"></a>Scenario - Add or Update Rejected</h5>

<ol>
        <li>Consumer requests that a named ACL be added or updated with the appropriate information.</li>
        <li>Named ACL Subsystem determines that the ACL should not be added or updated.</li>
        <li>The Named ACL Subsystem rejects the request.</li>
        <li>The Consumer warns the system (and relevant security frameworks) of a configuration error.</li>
</ol>


<h5><a name="NamedACLs-Postconditions"></a>Postconditions</h5>

<ul>
        <li>No change in the configuration of the Consumer or the Named ACL Subsystem</li>
</ul>


<h1><a name="NamedACLs-Design"></a>Design</h1>

<h2><a name="NamedACLs-NamedACLsubsystem"></a>Named ACL subsystem</h2>

<p>The Named ACL subsystem is responsible for reading ACLs from configurations and the realtime database and pushing events about ACL changes to consumers when required. Changes may occur for numerous reasons including reloads of the ACL configuration, requests made by consumers, and possibly others.  When a change occurs, the named ACL subsystem will create and fire an ACL change event indicating the nature of the change so that it can be picked up by the subscriber's callback and reacted to appropriately.</p>

<h2><a name="NamedACLs-ACLConsumerUsage"></a>ACL Consumer Usage</h2>

<h3><a name="NamedACLs-astaclstructure"></a>ast_acl structure</h3>

<p>The concept of an ast_acl should replace the usage of ast_ha structs at the consumer level.<br/>
The ast_acl struct is similar to the current ast_ha struct in that it is a linked list of rules.  Instead of each node being a single rule though, each node contains a list of rules. The whole thing could be written as an index.<br/>
example:</p>
<ul>
        <li>The non-named ACL component
        <ol>
                <li>deny all</li>
                <li>permit ha1</li>
                <li>permit ha2</li>
                <li>permit ha3</li>
        </ol>
        </li>
        <li>name1 (blacklist)
        <ol>
                <li>permit all</li>
                <li>deny ha4</li>
                <li>deny ha5</li>
        </ol>
        </li>
        <li>name2<br/>
...</li>
        <li>name3<br/>
...</li>
</ul>


<p>When evaluating an ast_acl structure, each individual ACL within the list will be evaluated separately against the provided address.&nbsp; The application will return with AST_SENSE_PERMIT if and only if all of the applications of that individual ACLs return AST_SENSE_PERMIT. If any of the rules return AST_SENSE_DENY, the whole ACL will return AST_SENSE_DENY.</p>

<p>This approach is useful because it makes updating ACL containers easy.&nbsp; If we want to update a whole container, we can simply iterate through the named elements of the ast_acl and ast_free_ha the head of each list and attach a fresh duplicate retrieved from the named ACL subsystem.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=20185274&revisedVersion=15&originalVersion=14">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>