Further openid work

This commit is contained in:
bluepython508
2023-11-11 23:57:09 +00:00
parent 4107d37106
commit aaff151be7
8 changed files with 39 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ mixRelease rec {
mixFodDeps = fetchMixDeps { mixFodDeps = fetchMixDeps {
pname = "mix-deps-${pname}"; pname = "mix-deps-${pname}";
inherit version src; inherit version src;
sha256 = "sha256-p74p7Dpi1xzddD+dygKF5cSLDATNKRXziKPNQgIhRPc="; sha256 = "sha256-tBWcGVLXEH1A55snOrSiA3Z3T0T8AHlpf0p5qi2nObw=";
}; };
postBuild = '' postBuild = ''
ln -sfv ${tailwindcss}/bin/tailwindcss _build/tailwind-linux-x64 ln -sfv ${tailwindcss}/bin/tailwindcss _build/tailwind-linux-x64

View File

@@ -36,7 +36,8 @@ defmodule SsoBsn.Interactive do
"client_secret_post", "client_secret_post",
"client_secret_jwt", "client_secret_jwt",
"private_key_jwt" "private_key_jwt"
] ],
id_token_signature_alg: "RS256"
} }
|> Map.merge(opts |> Enum.into(%{})) |> Map.merge(opts |> Enum.into(%{}))
) )

View File

@@ -2,10 +2,13 @@ defmodule SsoBsnWeb.Openid.ConfigurationController do
use SsoBsnWeb, :controller use SsoBsnWeb, :controller
def config(conn, _params) do def config(conn, _params) do
conn |> json(%{ conn
|> json(%{
issuer: url(~p"/"), issuer: url(~p"/"),
authorization_endpoint: url(~p"/openid/authorize"), authorization_endpoint: url(~p"/openid/authorize"),
token_endpoint: url(~p"/oauth/token") token_endpoint: url(~p"/oauth/token"),
jwks_uri: url(~p"/openid/jwks"),
userinfo_endpoint: url(~p"/openid/userinfo")
}) })
end end
end end

View File

@@ -0,0 +1,14 @@
defmodule SsoBsnWeb.Webfinger do
use SsoBsnWeb, :controller
plug :put_resp_content_type, "application/jrd+json"
def webfinger(conn, %{ "resource" => <<"acct:", _::bitstring>> = resource_uri }) do
conn |> json(%{
subject: resource_uri,
links: [
%{ rel: "http://openid.net/specs/connect/1.0/issuer", href: url(~p"/") }
]
})
end
end

View File

@@ -34,5 +34,8 @@ defmodule SsoBsnWeb.ResourceOwners do
@impl Boruta.Oauth.ResourceOwners @impl Boruta.Oauth.ResourceOwners
def claims(_resource_owner, _scope), do: %{} def claims(resource_owner, _scope), do: %{
username: resource_owner.username,
email: "#{resource_owner.username}@#{Application.get_env(:sso_bsn, :session_domain)}"
}
end end

View File

@@ -15,6 +15,7 @@ defmodule SsoBsnWeb.Router do
pipeline :api do pipeline :api do
plug :accepts, ["json"] plug :accepts, ["json"]
plug Corsica, origins: "*"
end end
scope "/", SsoBsnWeb do scope "/", SsoBsnWeb do
@@ -111,8 +112,9 @@ defmodule SsoBsnWeb.Router do
get "/authorize", AuthorizeController, :authorize get "/authorize", AuthorizeController, :authorize
end end
scope "/.well-known", SsoBsnWeb.Openid do scope "/.well-known", SsoBsnWeb do
pipe_through :api pipe_through :api
get "/openid-configuration", ConfigurationController, :config get "/openid-configuration", Openid.ConfigurationController, :config
get "/webfinger", Webfinger, :webfinger
end end
end end

View File

@@ -48,7 +48,8 @@ defmodule SsoBsn.MixProject do
{:dns_cluster, "~> 0.1.1"}, {:dns_cluster, "~> 0.1.1"},
{:plug_cowboy, "~> 2.5"}, {:plug_cowboy, "~> 2.5"},
{:wax_, "~> 0.6.0"}, {:wax_, "~> 0.6.0"},
{:boruta, "~> 2.3.0"} {:boruta, "~> 2.3.0"},
{:corsica, "~> 2.1.0"}
] ]
end end

View File

@@ -6,6 +6,7 @@
"cbor": {:hex, :cbor, "1.0.1", "39511158e8ea5a57c1fcb9639aaa7efde67129678fee49ebbda780f6f24959b0", [:mix], [], "hexpm", "5431acbe7a7908f17f6a9cd43311002836a34a8ab01876918d8cfb709cd8b6a2"}, "cbor": {:hex, :cbor, "1.0.1", "39511158e8ea5a57c1fcb9639aaa7efde67129678fee49ebbda780f6f24959b0", [:mix], [], "hexpm", "5431acbe7a7908f17f6a9cd43311002836a34a8ab01876918d8cfb709cd8b6a2"},
"cc_precompiler": {:hex, :cc_precompiler, "0.1.8", "933a5f4da3b19ee56539a076076ce4d7716d64efc8db46fd066996a7e46e2bfd", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "176bdf4366956e456bf761b54ad70bc4103d0269ca9558fd7cee93d1b3f116db"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.8", "933a5f4da3b19ee56539a076076ce4d7716d64efc8db46fd066996a7e46e2bfd", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "176bdf4366956e456bf761b54ad70bc4103d0269ca9558fd7cee93d1b3f116db"},
"comeonin": {:hex, :comeonin, "5.4.0", "246a56ca3f41d404380fc6465650ddaa532c7f98be4bda1b4656b3a37cc13abe", [:mix], [], "hexpm", "796393a9e50d01999d56b7b8420ab0481a7538d0caf80919da493b4a6e51faf1"}, "comeonin": {:hex, :comeonin, "5.4.0", "246a56ca3f41d404380fc6465650ddaa532c7f98be4bda1b4656b3a37cc13abe", [:mix], [], "hexpm", "796393a9e50d01999d56b7b8420ab0481a7538d0caf80919da493b4a6e51faf1"},
"corsica": {:hex, :corsica, "2.1.3", "dccd094ffce38178acead9ae743180cdaffa388f35f0461ba1e8151d32e190e6", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "616c08f61a345780c2cf662ff226816f04d8868e12054e68963e95285b5be8bc"},
"cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
"cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"},