<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>no</td>
</tr>
<tr>
<td>Feature request?</td>
<td>yes</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>4.1</td>
</tr>
</tbody>
</table>
<p dir="auto">Recall for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="219854798" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/22308" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/22308/hovercard" href="https://github.com/symfony/symfony/issues/22308">#22308</a> :)</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# security.yaml
firewalls:
    # ....
    api:
        pattern: ^/api
        stateless: true
        anonymous: true
    # ..."><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> security.yaml</span>
<span class="pl-ent">firewalls</span>:
    <span class="pl-c"><span class="pl-c">#</span> ....</span>
    <span class="pl-ent">api</span>:
        <span class="pl-ent">pattern</span>: <span class="pl-s">^/api</span>
        <span class="pl-ent">stateless</span>: <span class="pl-c1">true</span>
        <span class="pl-ent">anonymous</span>: <span class="pl-c1">true</span>
    <span class="pl-c"><span class="pl-c">#</span> ...</span></pre></div>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# bundle extension
public function prepend(ContainerBuilder $container)
{
    $security = $container-&gt;getExtensionConfig('security');
    $security[0]['firewalls']['api']['anonymous'] = false;
    $security[0]['firewalls']['api']['fos_oauth'] = true;

    $container-&gt;loadFromExtension('security', $security[0]);
}"><pre class="notranslate"><span class="pl-c"># bundle extension</span>
<span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">prepend</span>(<span class="pl-smi"><span class="pl-smi">ContainerBuilder</span></span> <span class="pl-s1"><span class="pl-c1">$</span>container</span>)
{
    <span class="pl-s1"><span class="pl-c1">$</span>security</span> = <span class="pl-s1"><span class="pl-c1">$</span>container</span>-&gt;<span class="pl-en">getExtensionConfig</span>(<span class="pl-s">'security'</span>);
    <span class="pl-s1"><span class="pl-c1">$</span>security</span>[<span class="pl-c1">0</span>][<span class="pl-s">'firewalls'</span>][<span class="pl-s">'api'</span>][<span class="pl-s">'anonymous'</span>] = <span class="pl-c1">false</span>;
    <span class="pl-s1"><span class="pl-c1">$</span>security</span>[<span class="pl-c1">0</span>][<span class="pl-s">'firewalls'</span>][<span class="pl-s">'api'</span>][<span class="pl-s">'fos_oauth'</span>] = <span class="pl-c1">true</span>;

    <span class="pl-s1"><span class="pl-c1">$</span>container</span>-&gt;<span class="pl-en">loadFromExtension</span>(<span class="pl-s">'security'</span>, <span class="pl-s1"><span class="pl-c1">$</span>security</span>[<span class="pl-c1">0</span>]);
}</pre></div>
<p dir="auto">Result</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Configuration path &quot;security.access_control&quot; cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section."><pre class="notranslate"><code class="notranslate">Configuration path "security.access_control" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.
</code></pre></div>
<p dir="auto">I understand <code class="notranslate">loadFromExtension</code> adds a new config branch (<code class="notranslate">$configs[] = $config</code>). But im trying to fake 1 config branch, so i guess i need reflection to clear current branch first.</p>
<p dir="auto">Can we create API for that? Or what about allowing overwrites on existing elements?</p>
<p dir="auto">Thx!</p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>yes</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.4 ? maybe also before</td>
</tr>
</tbody>
</table>
<p dir="auto">In the sulu recipe, we will add another file which adds the firewall to the existing configuration. This is not really possible without manually adding the <code class="notranslate">admin</code> key inside the <code class="notranslate">security.yaml</code> file!</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/stof/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/stof">@stof</a> hopefully you will add your thought which we have at the #SymfonyConHackday2017</p>