Skip to content

Add oidcc_authorization:validate_iss_parameter/2 for RFC 9207 - #580

Open
ardraayyappath wants to merge 3 commits into
erlef:mainfrom
ardraayyappath:harden/authorization-response-iss-helper
Open

ardraayyappath wants to merge 3 commits into
erlef:mainfrom
ardraayyappath:harden/authorization-response-iss-helper

Conversation

@ardraayyappath

Copy link
Copy Markdown
Contributor

oidcc leaves the authorization callback to the caller, so RFC 9207 issuer validation has to happen there.
oidcc_plug does this in its callback, but anyone writing their own callback (plain Erlang, Cowboy, a custom
Plug) has to reimplement the rules. This adds a small helper so they don't have to:

ok = oidcc_authorization:validate_iss_parameter(IssOrUndefined, ClientContext)

Behaviour (RFC 9207 §2.4):

iss in the callback authorization_response_iss_parameter_supported Result
present, matches the issuer either ok
present, does not match either {error, {invalid_iss_parameter, Iss}}
absent true {error, missing_iss_parameter}
absent false ok

If the issuer_regex quirk is configured, iss is matched against it, the same way the ID token iss
claim is.

Changes:

  • src/oidcc_authorization.erl: validate_iss_parameter/2 and the iss_error() type.
  • lib/oidcc/authorization.ex: Oidcc.Authorization.validate_iss_parameter/2 (takes nil for absent).
  • README.md: the RFC 9207 entry now says where the check happens (this helper, or oidcc_plug).
  • Tests: test/oidcc_authorization_test.erl covers every row above plus issuer_regex;
    test/oidcc/authorization_test.exs smoke-tests the Elixir wrapper (plus a doctest).

Testing (OTP 29 / Elixir 1.20): rebar3 fmt --check clean, rebar3 eunit 149 tests 0 failures,
rebar3 dialyzer clean, mix format --check-formatted clean, mix test 82 passed.

I used since: 3.10.0. Happy to change that, the names, or the error atoms. If this is wanted, a
follow-up for oidcc_plug could call it too. That would also compare a present iss when the provider
doesn't advertise support, which RFC 9207 asks clients to do.

oidcc does not handle the authorization callback, so RFC 9207 issuer
validation has to happen in the caller. Add a helper that applies the
RFC 9207 rules against the client context (honouring issuer_regex), expose
it in Oidcc.Authorization, and point to it from the README.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant