Skip to content

Commit

Permalink
handle 503 - service unavailable from token endpoint correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tarzan committed May 24, 2019
1 parent 909d144 commit 30818a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/ueberauth/adfs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ defmodule Ueberauth.Strategy.ADFS do

{:error, %OAuth2.Response{body: %{"error_description" => reason}}} ->
set_errors!(conn, [error("Authentication Error", reason)])

{:error, %OAuth2.Response{body: _, status_code: 503}} ->
set_errors!(conn, [
error("Authentication Error", "Service Unavailable - Contact the identity provider")
])
end
end

Expand Down
3 changes: 1 addition & 2 deletions test/ueberauth_adfs/adfs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ defmodule Ueberauth.Strategy.ADFSTest do
client_id: "example_client",
resource_identifier: "example_resource"


@env_handler_values adfs_url: "https://example.com",
adfs_metadata_url: "https://example.com/metadata.xml",
adfs_handler: Ueberauth.Strategy.ADFSTestHandler,
Expand Down Expand Up @@ -185,7 +184,7 @@ defmodule Ueberauth.Strategy.ADFSTest do
[error] = ADFS.handle_callback!(%Plug.Conn{params: %{"code" => "1234"}})

assert error == %Ueberauth.Failure.Error{
message: "Service Unavailable",
message: "Service Unavailable - Contact the identity provider",
message_key: "Authentication Error"
}
end
Expand Down

0 comments on commit 30818a2

Please sign in to comment.