freckle / yesod-auth-oauth2

OAuth2 authentication for yesod
MIT License
71 stars 53 forks source link

Add support for error handling #106

Closed eborden closed 6 years ago

eborden commented 6 years ago

The OAuth2 spec outlines error handling responses in the case of a bad request. Currently this plugin will fail to parse an error callback, but will throw:

{"message":"Invalid Arguments","errors":["The 'code' parameter is required"]}

via a url like

/auth/page/classlink/callback?error=redirect_uri_mismatch&error_description=invalid%20redirect%20url&response_type=code&state=dfzsiedckqixxpdzqjdxoaxkdsshmm

The likely point of update is here: https://github.com/thoughtbot/yesod-auth-oauth2/blob/a91f85ff38e5e04b61311bd0332e06ce19af72f9/src/Yesod/Auth/OAuth2/Dispatch.hs#L59

The error response is outlined in https://tools.ietf.org/html/rfc6749#section-4.1.2.1