puiterwijk / flask-oidc

OpenID Connect support for Flask
BSD 2-Clause "Simplified" License
154 stars 217 forks source link

How to replace the "Not Authorized" error page #103

Open sanjuroj opened 4 years ago

sanjuroj commented 4 years ago

Hello,

I have a question about error handling. I'm connecting an application to Okta and it's all working very well (thanks by the way, it was very straightforward with your module). The one issue I have is that when a user has a valid account in Okta, but is not authorized to use the application I'm building, they get a page that simply says "Not Authorized" with something like this in the address bar:

https://mydomain.com/authorization-code/callback?state=XXXXXXXXXXXXXX&error=access_denied&error_description=User+is+not+assigned+to+the+client+application.

I'm assuming what's going on is that, because there was an authorization error, the _oidc_error method is being called, and "Not Authorized" is displayed as the default message.

I'd like to provide a more user-friendly error page as part of the app I'm writing. Is overriding the _oidc_error method of the OpenIDConnect class the way to do this? Or is there a better way?