<h1>Configuring authorization<aclass="headerlink" href="#configuring-authorization" title="Link to this heading">¶</a></h1>
<sectionid="introduction">
<h2>Introduction<aclass="headerlink" href="#introduction" title="Link to this heading">¶</a></h2>
<p>Source.Python provides an authorization package that can be used by plugins to
check whether a player is granted a specific permission. There are two object
types that can have permissions:</p>
<ulclass="simple">
<li><p>Players</p></li>
<li><p>Parents</p></li>
</ul>
<p>Parents can be used to create a set of permissions (like groups or roles).
Both, players and parents, can inherit permissions from parents, allowing a
flexible and dynamic permission hierarchy.</p>
<p>Before granting permissions and creating parents, you need to choose an
authorization backend.</p>
</section>
<sectionid="backends">
<h2>Backends<aclass="headerlink" href="#backends" title="Link to this heading">¶</a></h2>
<p>The backend defines how permissions are stored. Currently, you can choose
between two built-in backends:</p>
<ulclass="simple">
<li><p>Flatfile</p></li>
<li><p>SQL</p></li>
</ul>
<p>To define which backend should be used, please open <codeclass="docutils literal notranslate"><spanclass="pre">core_settings.ini</span></code> and
specify the backend you want to use in the <codeclass="docutils literal notranslate"><spanclass="pre">AUTH_SETTINGS</span></code> section. Backend
specific settings are provided in sub-sections within the <codeclass="docutils literal notranslate"><spanclass="pre">BACKENDS</span></code> section.</p>
<p>The above example creates a new group called <codeclass="docutils literal notranslate"><spanclass="pre">administrator</span></code> which is able
to execute every permission defined by the <codeclass="docutils literal notranslate"><spanclass="pre">admin</span></code> plugin. Every player
or parent that inherits from this parent is able to execute <codeclass="docutils literal notranslate"><spanclass="pre">admin.kick</span></code>
and <codeclass="docutils literal notranslate"><spanclass="pre">admin.ban</span></code>. In case the plugin author of <codeclass="docutils literal notranslate"><spanclass="pre">admin</span></code> adds in another
permission (e.g. <codeclass="docutils literal notranslate"><spanclass="pre">admin.burn</span></code>) all players and parents inheriting from
<codeclass="docutils literal notranslate"><spanclass="pre">administrator</span></code> will automatically have the permission to execute
<codeclass="docutils literal notranslate"><spanclass="pre">admin.burn</span></code>, because the asterisk symbol (*) matches all subnodes.</p>
<p>The third file is a simple text file that grants all players that have been
added to this file the permission to execute everything and all.</p>
<p>Example content for <codeclass="docutils literal notranslate"><spanclass="pre">simple.txt</span></code>:</p>
<h3>SQL<aclass="headerlink" href="#sql" title="Link to this heading">¶</a></h3>
<p>The SQL backend is a more advanced backend and is a good choice in the
following situations:</p>
<ulclass="simple">
<li><p>You run multiple server and want to share the permissions across all servers.</p></li>
<li><p>You want to use <aclass="reference external" href="http://github.com/necavi/SP-Webmin">SP-Webmin</a> for advanced multi-server management.</p></li>
</ul>
<p>Currently, the auth API officially only supports SQLite and MySQL, but as it is
implemented using SQLAlchemy it should work on other database engines such as
Postgre.</p>
<sectionid="sqlite-configuration">
<h4>SQLite configuration<aclass="headerlink" href="#sqlite-configuration" title="Link to this heading">¶</a></h4>
<spanclass="na">uri</span><spanclass="w"></span><spanclass="o">=</span><spanclass="w"></span><spanclass="s">sqlite://<path to database file></span>
<h2>Adding, modifying and deleting permissions and parents<aclass="headerlink" href="#adding-modifying-and-deleting-permissions-and-parents" title="Link to this heading">¶</a></h2>
<p>You can always add, modify and delete permissions and parents by accessing the
JSON files or SQL database directly. However, Source.Python also provides
server commands to do these tasks. <aclass="reference internal" href="sp-commands.html"><spanclass="doc">You might want to try them.</span></a></p>
</section>
<sectionid="assigning-permissions-to-guests">
<h2>Assigning permissions to guests<aclass="headerlink" href="#assigning-permissions-to-guests" title="Link to this heading">¶</a></h2>
<p>There is a special parent called <codeclass="docutils literal notranslate"><spanclass="pre">guest</span></code> which can be used to assign
permissions to anonymous players. Every player on the server is a member of
<li><aclass="reference internal" href="#adding-modifying-and-deleting-permissions-and-parents">Adding, modifying and deleting permissions and parents</a></li>
<li><aclass="reference internal" href="#assigning-permissions-to-guests">Assigning permissions to guests</a></li>