<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="110424" data-post-id="110424">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="MilosMosovsky" data-post="11" data-topic="19183">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/milosmosovsky/48/13445_2.png" class="avatar"> MilosMosovsky:</div>
<blockquote>
<p>ETS table is very small as it is cleared on each <code>load_and_authorize_performer</code> and <code>permissions</code> macro. But I imaginage to have some cache there and sweeper which will truncate the cache after some time.</p>
</blockquote>
</aside>
<p>Uh, cleared on each?  What if you have two concurrent requests coming in?  Doesn’t that mean that one could potentially get the others permissions or get no permissions or some combination thereof?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110424" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/terminator-granular-elixir-acl-permissions-library-suggestions-thoughts/19183/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-110424" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110424"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="110661" data-post-id="110661">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bjunc" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bjunc/120/16781_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bjunc
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I created a library a little while back called <a href="https://github.com/bjunc/access-decision-manager" rel="noopener nofollow ugc">Access Decision Manager</a>.  I think it might do what you’re looking for.  It’s based on logic by the same name in PHP’s Symfony framework.  Quick examples:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">granted?(viewer, "CREATE_FOO", some_entity) # true / false
</code></pre>
<p>This uses a “voter” system that allows for per-entity permissions.  You can also use it for simpler scenarios like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">granted?(viewer, "ROLE_SUPER_ADMIN")
</code></pre>
<p>This is where the “subject” and “entity” are the same (eg. you want to know if the viewer has the super admin role).</p>
<p>We’re currently using this in production, in both Guardian plugs, as well as Absinthe resolvers.  Slightly paired back resolver example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def update(%{input: %{id: floor_plan_id}}, %{context: %{viewer: viewer}}) do
    case FloorPlan.get(floor_plan_id) do  
      %FloorPlan{} = floor_plan -&gt;
        if granted?(viewer, "EDIT_FLOOR_PLAN", floor_plan.project) do
          # ... update floor plan

        else
          {:error, message: "Permission denied.", code: 403}
        end

      nil -&gt;
        {:error, message: "Floor Plan doesn't exist.", code: 404}
    end
  end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110661" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/terminator-granular-elixir-acl-permissions-library-suggestions-thoughts/19183/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-110661" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110661"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>