Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 1.97 KB

File metadata and controls

74 lines (53 loc) · 1.97 KB

Error resources

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]

Next Steps

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.

Improving the 401 error

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.

Example 1. Installing a better 401 error page

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]
Example 2. Testing the authentication

If we now nagivate to https://site.test/protected.html we get the following:

Unauthorized
Figure 1. Unauthorized

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].