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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Got a couple things:</p>
<p>The <code>set_actor</code> plug puts the actor in an idiomatic place on the conn. But it doesn’t call <code>Ash.set_actor/1</code>, that is an “opt-in” tool for storing the actor in the process dictionary.</p>
<p>What I would generally suggest (and will be default in Ash 3.0) is to set this in your api:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">authorization do
  authorize :by_default
end
</code></pre>
<p>Then authorization will always be running unless you explicitly pass <code>authorize?: false</code>. Not passing an actor is equivalent to <code>actor: nil</code>, but in the default setup, not passing an actor is equivalent to <code>authorize?: false</code>.</p>
<p>If there is a “current actor” then I’d set it as the actor. If its an authentication action, then you can do things like <code>authorize_unless actor_present()</code> to only allow calling it without an actor. You could also add <code>forbid_if always()</code> to make it so that it can <em>only</em> be called with <code>authorize?: false</code>. That is a good way to make something internal only (because api clients and things like that can’t pass <code>authorize?: false</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="286870" 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/ash-authentication-on-mobile/55568/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-286870" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="286870"
                     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="286900" data-post-id="286900">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lud" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/120/14382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lud
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks, I’m moving slowly but it works. I have set the policies to allow users to read their own inventories only.</p>
<p>I removed the default <code>:create</code> action on the inventory and defined it like this, with the relationships:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">actions do
    defaults([:read, :update, :destroy])

    create :create do
      accept([:title])
      argument(:owner, :uuid, allow_nil?: false)
      change(manage_relationship(:owner, :owner, type: :append))
    end
end

  relationships do
    belongs_to :owner, User do
      api(Accounts)
      allow_nil?(false)
    end
  end
</code></pre>
<p>Because an inventory always need to belong to a user.</p>
<p>And now I can pass the user.id as <code>:owner</code> to my action, from the controller:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def create(conn, params) do
    user = auth_actor(conn)

    params =
      params
      |&gt; Map.delete("owner")
      |&gt; Map.put(:owner, user.id)

    Inventory
    |&gt; Ash.Changeset.for_create(:create, params, actor: user)
    |&gt; Inventories.create()
    |&gt; on_ok do
      inventory -&gt;
        conn |&gt; put_status(201) |&gt; render("inventory.json", %{inventory: inventory})
    end
  end

  def show(conn, %{"id" =&gt; id}) do
    id
    |&gt; Inventory.get_by_id(actor: auth_actor(conn))
    |&gt; on_ok do
      inventory -&gt;
        conn |&gt; put_status(200) |&gt; render("inventory.json", %{inventory: inventory})
    end
  end
</code></pre>
<p>Finally I can define my policies in the <code>Inventory</code> resource like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  policies do
    policy action_type(:read) do
      authorize_if(relates_to_actor_via(:owner))
    end

    policy action_type(:create) do
      authorize_if(always())
    end
  end
</code></pre>
<p>For it to work I had to add the following to my <code>User</code> resource:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  actions do
    defaults([:read])
  end
</code></pre>
<p>I guess it’s because the policy checker needs to read from the user resource. Which I do not understand because I pass the actor in <code>Inventory.get_by_id(actor: auth_actor(conn))</code> and I believe that <code>authorize_if(relates_to_actor_via(:owner))</code> should only compare the <code>id</code> from the inventory resource to that actor id. But I believe it is because the <code>:owner</code> relationship could point to a FK that is not on the primary key of the user, and that field could not be loaded by default in the actor.</p>
<p><a class="mention" href="/u/zachdaniel" rel="nofollow">@zachdaniel</a> I’ll answer to this topic as a discover log of your framework. Do not feel obligated to answer. I hope it can help some people following the same path. Though I have a question: with that setup, I get a <code>Ash.Error.Query.NotFound</code> error when the actor is not the actual owner. Is it possible to get a policy error? Because I want users to be able to authorize other users to read and/or change an inventory, via a new resource (called Allowance or something). So I really need to know from the client app if the inventory exists or not when not authorized.</p>
<p>Thank you a lot for your support so far.</p>
<p>Edit: the formatting has a lot of parentheses because for some reason my VSCode adds them. It looks like ElixirLS is always compiling. I found a github issue about this. At some point I stopped fighting and learnt to love the parens <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p>Edit: I tried with this but nobody can access the resource:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    policy action_type(:read) do
      forbid_unless(relates_to_actor_via(:owner))
    end
</code></pre>
<p>But I do get a Forbidden error though.</p>
<p>I modified the <code>relates_to_actor_via</code> function to make it print some debug and raise. It does not seem to be called when used by <code>forbid_unless</code>!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="286900" 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/ash-authentication-on-mobile/55568/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-286900" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="286900"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="287168" data-post-id="287168">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lud" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/120/14382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lud
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/zachdaniel" rel="nofollow">@zachdaniel</a> I found <a href="https://discord.com/channels/711271361523351632/1084767908363776071/1084979009110167562" rel="noopener nofollow ugc">this example</a> I’ll try that <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Edit:</p>
<p>Well I tried different combinations but it will not work</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    # Results in Not Found
    policy action_type(:read) do
      forbid_unless(relates_to_actor_via(:owner))
      authorize_if(always())
    end

    # Results in Not Found
    policy action_type(:read) do
      authorize_if(relates_to_actor_via(:owner))
      forbid_if(always())
    end

    # Results in Not Found
    policy action_type(:read) do
      authorize_if(relates_to_actor_via(:owner))
    end
</code></pre>
<p>I also tried a custom simple check but it does not receive a changeset like in the Discord example. I get a query though, but with that I would end up building a filter too.</p>
<p>I feel like as the action is defined with <code>get?(true)</code> it should allow to run filters after the entity has been pulled from the database instead of building a filter.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287168" 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/ash-authentication-on-mobile/55568/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-287168" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287168"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="287193" data-post-id="287193">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Have you read through the policies guide? <a href="https://ash-hq.org/docs/guides/ash/latest/topics/policies" class="inline-onebox" rel="noopener nofollow ugc">Policies — ash v3.29.3</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287193" 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/ash-authentication-on-mobile/55568/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-287193" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287193"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="287194" data-post-id="287194">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lud" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/120/14382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lud
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes but I could not understand how to not use a filter check, except when using a custom check but that check receives a query and not the entity, so it will be a custom fetch in DB and check … so why not just check in the controller.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287194" 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/ash-authentication-on-mobile/55568/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-287194" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287194"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="287195" data-post-id="287195">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Might also be worth pointing out that we have a JSON:API extension that will do all of the json api work for you. <a href="https://ash-hq.org/docs/guides/ash_json_api/latest/tutorials/getting-started-with-json-api" rel="noopener nofollow ugc">https://ash-hq.org/docs/guides/ash_json_api/latest/tutorials/getting-started-with-json-api</a></p>
<p>So there are a couple things I think you need to know.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    policy action_type(:read) do
      forbid_unless(relates_to_actor_via(:owner))
    end
</code></pre>
<p>This policy will always fail. A policy is read from top to bottom, and something in the policy must set the status to <code>authorized</code>. If nothing does, then we assume <code>forbidden</code>.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    policy action_type(:read) do
      forbid_unless(relates_to_actor_via(:owner))
      authorize_if always()
    end
</code></pre>
<p>would do it, but what you probably want instead would be</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    policy action_type(:read) do
      authorize_if relates_to_actor_via(:owner)
    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="287195" 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/ash-authentication-on-mobile/55568/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-287195" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287195"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="287196" data-post-id="287196">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Returning a <code>Forbidden</code> when filter checks don’t match actually a security issue, which is why we favor filter checks wherever possible. For security reasons, we hide from the outside world that the thing you tried to read exists. i.e an endpoint like <code>/users?username=foo</code> returning <code>Forbidden</code> when there is a user with that username, and <code>Not Found</code> when there isn’t.</p>
<p>I think in your case the custom check may be the way to go, and/or a manual/basic action or one of the other escape hatches that we offer for running custom behavior.</p>
<p>Generic Actions (more at the bottom of the page): <a href="https://ash-hq.org/docs/guides/ash/latest/topics/actions#generic-actions" class="inline-onebox" rel="noopener nofollow ugc">Actions — ash v3.29.3</a></p>
<p>Manual Actions:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://ash.hexdocs.pm/manual-actions.html">
  <header class="source">

      <a href="https://ash.hexdocs.pm/manual-actions.html" target="_blank" rel="noopener nofollow ugc">ash.hexdocs.pm</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://ash.hexdocs.pm/manual-actions.html" target="_blank" rel="noopener nofollow ugc">Manual Actions — ash v3.29.3</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>You could also model it as two resources:<br>
one resource that everyone can see, and one that only some of them can see. Then wether or not the user can see the related thing could be a calculation: <a href="https://ash-hq.org/docs/guides/ash/latest/topics/calculations" class="inline-onebox" rel="noopener nofollow ugc">Calculations — ash v3.29.3</a></p>
<p>For the simplest case, I think you might even just do something like this and bypass policies:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">
actions do
  defaults [:read]

  action :get_inventory_by_id do
    get? true
    argument :id, :uuid, allow_nil?: false
    filter expr(id == ^arg(:id)

    prepare fn query, _ -&gt; 
      Ash.Query.after_action(query, fn _query, results -&gt; 
        if YourApi.can?(__MODULE__, :read, data: results) do
          {:ok, results}
        else
          {:error, Ash.Error.Forbidden.exception()}
        end
      end)
    end
  end
end

policies do
  # let anyone run this action
  policy action(:get_inventory_by_id) do
    authorize_if always()
  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="287196" 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/ash-authentication-on-mobile/55568/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-287196" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287196"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="287197" data-post-id="287197">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>See the actions guide for more information on lifecycle hooks around actions (i.e <code>Ash.Query.after_action</code> and <code>prepare</code>).</p>
<p>If you are going to be handwriting your controllers, I’d also suggest looking into the <code>code_interface</code>. <a href="https://ash-hq.org/docs/guides/ash/latest/topics/code-interface" rel="noopener nofollow ugc">https://ash-hq.org/docs/guides/ash/latest/topics/code-interface</a></p>
<p>For that example action above, you could do:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">code_interface do
  define_for Inventories
  define :get_by_id, args: [:id]
end
</code></pre>
<p>And then in your controller you could then do</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Inventory.get_by_id(id)
</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="287197" 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/ash-authentication-on-mobile/55568/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-287197" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287197"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="287251" data-post-id="287251">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lud" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/120/14382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lud
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes I have the custom actions from the tutorial! That’s neat.</p>
<p>I understand why policies would fake a not-found result, but I do not think it should be a default, or at least an opt-out would be great.</p>
<p>So I have this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def show(conn, %{"id" =&gt; id}) do
    id
    |&gt; Inventory.get_by_id(actor: auth_actor(conn), verbose?: true, authorize?: true)
    |&gt; on_ok do
      inventory -&gt;
        conn |&gt; put_status(200) |&gt; render("inventory.json", %{inventory: inventory})
    end
  end
</code></pre>
<p>And tried with this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  authorization do
    authorize :always # also tried :by_default
  end
</code></pre>
<p>And this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"> actions do
    defaults([:read, :update, :destroy])

    read :by_id do
      argument(:id, :uuid, allow_nil?: false)
      get?(true)
      filter(expr(id == ^arg(:id)))

      prepare(fn query, ctx -&gt;
        Ash.Query.after_action(query, fn query, results -&gt;
          if Inventories.can?(query, ctx.actor, data: results, authorize?: true) do
            {:ok, results}
          else
            {:error, Ash.Error.Forbidden.exception("nope")}
          end
        end)
      end)
    end
</code></pre>
<p>I can see this log:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">23:27:41.836 request_id=F1wN6pBOa0NzB0wAAAUB [debug] process MyApp.Inventories.Inventory.by_id: 1 Skipping check due to `authorize?: false`
</code></pre>
<p>And the check always returns true, it is not forbidding anyone.</p>
<p>I’ll just handle this in the controller for now, but thank you a lot for the support, it’s nice to try a new framework!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287251" 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/ash-authentication-on-mobile/55568/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-287251" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287251"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="287252" data-post-id="287252">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Whats wrong with writing the custom check as you mentioned originally? Then you don’t have to do it in the controller. The general goal for building with Ash is to put as much of this stuff in the resource, to encapsulate the domain operation happening. Most people using Ash won’t even have controllers because they’ll use an api extension <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287252" data-batch-url="/posts/batch_likers">
                        1
                      </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/ash-authentication-on-mobile/55568/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-287252" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287252"
                     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 #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/55568/load_more?page=3">Load more posts (3 remaining)</a>
</div></template></turbo-stream>