Site allows errors to be represented with custom representations.
First, create an error resource.
link:../../test/juxt/book.clj[role=include]link:../../test/juxt/book.clj[role=include]link:../../test/juxt/book.clj[role=include]link:../../test/juxt/book.clj[role=include]We have a protected resource but the 401 status response tells us we are not authorized to access it.
To authorize the subject we’ll need to first determine who is trying to access the resource.
If the user is using a browser, it’s a better user experience if we provide them with a button to click to take them through the authentication process, and return them to the original resource once they’ve been authenticated.
Installing a better 401 error page demonstrates how we can do this.
Remember the 401 Unauthorized response we got back in
[publishing-protected-resources]? Now we can at least authenticate the end-user.
link:../../test/juxt/book.clj[role=include]If we now nagivate to https://site.test/protected.html we get the following:
Clicking on btn:[Login] directs us to the Application Login URI that we have
installed for our OpenID Provider.
If all goes as expected, the error should change to a 403. This means we’ve successfully authenticated, but still don’t have the permission to view the protected resource. That’s a topic for [authorization].
