oauth/oidc
This commit is contained in:
31
lib/sso_bsn_web/controllers/oauth/revoke_controller.ex
Normal file
31
lib/sso_bsn_web/controllers/oauth/revoke_controller.ex
Normal file
@@ -0,0 +1,31 @@
|
||||
defmodule SsoBsnWeb.Oauth.RevokeController do
|
||||
@behaviour Boruta.Oauth.RevokeApplication
|
||||
|
||||
use SsoBsnWeb, :controller
|
||||
|
||||
alias Boruta.Oauth.Error
|
||||
alias SsoBsnWeb.OauthView
|
||||
|
||||
def oauth_module, do: Application.get_env(:sso_bsn, :oauth_module, Boruta.Oauth)
|
||||
|
||||
def revoke(%Plug.Conn{} = conn, _params) do
|
||||
conn |> oauth_module().revoke(__MODULE__)
|
||||
end
|
||||
|
||||
@impl Boruta.Oauth.RevokeApplication
|
||||
def revoke_success(%Plug.Conn{} = conn) do
|
||||
send_resp(conn, 200, "")
|
||||
end
|
||||
|
||||
@impl Boruta.Oauth.RevokeApplication
|
||||
def revoke_error(conn, %Error{
|
||||
status: status,
|
||||
error: error,
|
||||
error_description: error_description
|
||||
}) do
|
||||
conn
|
||||
|> put_status(status)
|
||||
|> put_view(OauthView)
|
||||
|> json(%{error: error, error_description: error_description})
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user