Skip to content

Commit

Permalink
make idp_id available to the pre_session_create_pipeline - fixes #45
Browse files Browse the repository at this point in the history
  • Loading branch information
handnot2 committed Mar 27, 2019
1 parent e109fb1 commit 77bb2d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ with the IdP but before a session is created.

This is just a vanilla Plug Pipeline. The SAML assertion from
the IdP is made available in the Plug connection as a "private".
(The pipeline plugs have access to the `idp_id` in this assertion.)
If you want to derive new attributes, create an Elixir map data (`%{}`)
and update the `computed` field of the SAML assertion and put it back
in the Plug connection private with `Conn.put_private` call.
Expand All @@ -311,6 +312,9 @@ defmodule MySamlyPipeline do
def compute_attributes(conn, _opts) do
assertion = conn.private[:samly_assertion]

# This assertion has the idp_id
# %Assertion{idp_id: idp_id} = assertion

first_name = Map.get(assertion.attributes, "first_name")
last_name = Map.get(assertion.attributes, "last_name")

Expand Down
1 change: 1 addition & 0 deletions lib/samly/sp_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ defmodule Samly.SPHandler do

with {:ok, assertion} <- Helper.decode_idp_auth_resp(sp, saml_encoding, saml_response),
:ok <- validate_authresp(conn, assertion, relay_state),
assertion = %Assertion{assertion | idp_id: idp_id},
conn = conn |> put_private(:samly_assertion, assertion),
{:halted, %Conn{halted: false} = conn} <- {:halted, pipethrough(conn, pipeline)} do
updated_assertion = conn.private[:samly_assertion]
Expand Down

0 comments on commit 77bb2d8

Please sign in to comment.