mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
Bring back browser/config.xml
This commit is contained in:
@@ -39,7 +39,7 @@ defmodule Web do
|
||||
def controller do
|
||||
quote do
|
||||
use Phoenix.Controller,
|
||||
formats: [:html, :json],
|
||||
formats: [:html, :json, :xml],
|
||||
layouts: [html: Web.Layouts]
|
||||
|
||||
import Plug.Conn
|
||||
@@ -67,6 +67,19 @@ defmodule Web do
|
||||
end
|
||||
end
|
||||
|
||||
def xml do
|
||||
quote do
|
||||
import Phoenix.Template, only: [embed_templates: 1]
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller,
|
||||
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
||||
|
||||
# Include general helpers for rendering HTML
|
||||
unquote(html_helpers())
|
||||
end
|
||||
end
|
||||
|
||||
def html do
|
||||
quote do
|
||||
use Phoenix.Component
|
||||
|
||||
7
apps/web/lib/web/controllers/browser_controller.ex
Normal file
7
apps/web/lib/web/controllers/browser_controller.ex
Normal file
@@ -0,0 +1,7 @@
|
||||
defmodule Web.BrowserController do
|
||||
use Web, :controller
|
||||
|
||||
def config(conn, _params) do
|
||||
render(conn, "config.xml", layout: false)
|
||||
end
|
||||
end
|
||||
5
apps/web/lib/web/controllers/browser_xml.ex
Normal file
5
apps/web/lib/web/controllers/browser_xml.ex
Normal file
@@ -0,0 +1,5 @@
|
||||
defmodule Web.BrowserXML do
|
||||
use Web, :xml
|
||||
|
||||
embed_templates "browser_xml/*"
|
||||
end
|
||||
9
apps/web/lib/web/controllers/browser_xml/config.xml.eex
Normal file
9
apps/web/lib/web/controllers/browser_xml/config.xml.eex
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square150x150logo src="<%= ~p"/images/mstile-150x150.png" %>" />
|
||||
<TileColor>331700</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
19
apps/web/lib/web/controllers/error_xml.ex
Normal file
19
apps/web/lib/web/controllers/error_xml.ex
Normal file
@@ -0,0 +1,19 @@
|
||||
defmodule Web.ErrorXML do
|
||||
use Web, :xml
|
||||
|
||||
# If you want to customize your error pages,
|
||||
# uncomment the embed_templates/1 call below
|
||||
# and add pages to the error directory:
|
||||
#
|
||||
# * lib/web_web/controllers/error_xml/404.xml.heex
|
||||
# * lib/web_web/controllers/error_xml/500.xml.heex
|
||||
#
|
||||
# embed_templates "error_xml/*"
|
||||
|
||||
# The default is to render a plain text page based on
|
||||
# the template name. For example, "404.xml" becomes
|
||||
# "Not Found".
|
||||
def render(template, _assigns) do
|
||||
Phoenix.Controller.status_message_from_template(template)
|
||||
end
|
||||
end
|
||||
15
apps/web/test/web/controllers/browser_controller_test.exs
Normal file
15
apps/web/test/web/controllers/browser_controller_test.exs
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule Web.BrowserControllerTest do
|
||||
use Web.ConnCase, async: true
|
||||
|
||||
describe "config/2" do
|
||||
test "returns valid XML browser config", %{conn: conn} do
|
||||
test_conn =
|
||||
conn
|
||||
# |> put_req_header("accept", "application/xml")
|
||||
|> get(~p"/browser/config.xml")
|
||||
|
||||
assert response(test_conn, 200) =~ "<?xml"
|
||||
assert response(test_conn, 200) =~ "src=\"/images/mstile-150x150.png\""
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -88,7 +88,11 @@ config :web, Web.Endpoint,
|
||||
path: nil
|
||||
],
|
||||
render_errors: [
|
||||
formats: [html: Web.ErrorHTML, json: Web.ErrorJSON],
|
||||
formats: [
|
||||
html: Web.ErrorHTML,
|
||||
json: Web.ErrorJSON,
|
||||
xml: Web.ErrorXML
|
||||
],
|
||||
layout: false
|
||||
],
|
||||
pubsub_server: Domain.PubSub,
|
||||
@@ -97,6 +101,10 @@ config :web, Web.Endpoint,
|
||||
signing_salt: "t01wa0K4lUd7mKa0HAtZdE+jFOPDDejX"
|
||||
]
|
||||
|
||||
config :mime, :types, %{
|
||||
"application/xml" => ["xml"]
|
||||
}
|
||||
|
||||
config :web, Web.SAML,
|
||||
entity_id: "urn:firezone.dev:firezone-app",
|
||||
certfile_path: Path.expand("../apps/web/priv/cert/saml_selfsigned.pem", __DIR__),
|
||||
|
||||
Reference in New Issue
Block a user