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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="root" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  root
                    <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>Okay…</p>
<p>router.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">...

  # put host and configuration data into session for retrieval from liveview
  defp sessionify_configuration(conn, _opts) do
    import Plug.Conn

    case MyApp.Sites.Domain.get_by_name(conn.host) do
      {:ok, domain} -&gt;
        configuration =
          domain.site_id
          |&gt; MyApp.Sites.Site.get_by_id!()
          |&gt; MyApp.Sites.load!(:configuration)
          |&gt; Map.get(:configuration)

        conn
        |&gt; put_session(:configuration, configuration)
        |&gt; put_session(:current_host, conn.host)
        |&gt; put_session(:current_path, conn.request_path)

      {:error, error} -&gt;
        IO.inspect(error)
        raise "No Domain found with the name " &lt;&gt; conn.host
        conn
    end
  end

  pipeline :do_config do
    plug :sessionify_configuration
  end

  scope "/", MyAppWeb do
    pipe_through [:browser, :do_config]

    # login not required
    ash_authentication_live_session :authenticated_optional,
      on_mount: [
        {MyAppWeb.LiveUserAuth, :live_user_optional},
        {MyAppWeb.AssignConfiguration, :assign_configuration}
      ] do

      live "/", PublicLive.Index, :index
    end

...
</code></pre>
<p>assign_configuration.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def on_mount(:assign_configuration, _params, session, socket) do
  socket =
    socket
    |&gt; Phoenix.Component.assign(:configuration, Map.get(session, "configuration"))
    |&gt; Phoenix.Component.assign(:current_host, Map.get(session, "current_host"))
    |&gt; Phoenix.Component.assign(:current_path, Map.get(session, "current_path"))

  {:cont, socket}
end
</code></pre>
<p>index.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def mount(_params, _session, socket) do
    socket =
      socket
      |&gt; assign(:page_title, "public")
      |&gt; assign(:testificate, "testificatey")

    layout = {MyAppWeb.Layouts, socket.assigns.configuration.theme}

    {:ok, socket, layout: layout}
  end
</code></pre>
<p>This is the flow I have right now that’s working! I was able to remove extraneous hooks and consolidate some functionality into the <code>on_mount</code>. And it looks like Phoenix actually is letting me pass the layout template as a string, too, although it does complain that this is deprecated. So no <code>String.to_atom</code> for now (and if I do have to do that later I think I can just whitelist it based on existing themes).</p>
<p>So the only thing I have to append to every liveview is</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">layout = {MyAppWeb.Layouts, socket.assigns.configuration.theme}
{:ok, socket, layout: layout}
</code></pre>
<p>Not <em>too</em> bad.</p>
<blockquote>
<p>And to be clear I meant like they could potentially manipulate the session based on the hostname. If you are whitelisting hostnames then it’s no problem.</p>
</blockquote>
<p>This area is all public stuff you can view by simply going to that site, so that <em>should</em> be fine as I understand it. Unless there’s anything drastic I’m missing.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287231" data-batch-url="/posts/batch_likers">
                        3
                      </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/setting-dynamic-layouts-in-liveviews-that-correspond-with-the-hostname/55664/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-287231" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287231"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="287244" data-post-id="287244">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="10" data-topic="55664">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>Session is definitely modifiable by user</p>
</blockquote>
</aside>
<p>The session is signed by default, so it is not editable by the user. You can also encrypt it to make it impossible for the user to view.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287244" 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/setting-dynamic-layouts-in-liveviews-that-correspond-with-the-hostname/55664/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-287244" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287244"
                     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="287245" data-post-id="287245">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ya, sorry, I clarified I meant if setting session variables based on user input ie if the user spoofs the hostname.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287245" 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/setting-dynamic-layouts-in-liveviews-that-correspond-with-the-hostname/55664/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-287245" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287245"
                     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="287322" data-post-id="287322">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="root" data-post="12" data-topic="55664">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/r/cc9497/48.png" class="avatar"> root:</div>
<blockquote>
<p>This area is all public stuff you can view by simply going to that site, so that <em>should</em> be fine as I understand it. Unless there’s anything drastic I’m missing.</p>
</blockquote>
</aside>
<p>Naw you’re good since you’re checking that the domains exist.  I was very tired yesterday and answering stuff in a hurry so apologies for any lack of clarity.  I was misusing “spoofing” too—I was talking about a worst-case scenario where one would take whatever subdomain is provided, immediately passing it to the session, then calling <code>String.to_atom/1</code> on it without any kind of checkst.  Obviously you are doing none of that so you’re good!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="287322" 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/setting-dynamic-layouts-in-liveviews-that-correspond-with-the-hostname/55664/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-287322" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="287322"
                     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>