Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Keycloak - Identity and Access Management for Modern Applications - Second Edition

You're reading from  Keycloak - Identity and Access Management for Modern Applications - Second Edition

Product type Book
Published in Jul 2023
Publisher Packt
ISBN-13 9781804616444
Pages 350 pages
Edition 2nd Edition
Languages
Authors (2):
Stian Thorgersen Stian Thorgersen
Profile icon Stian Thorgersen
Pedro Igor Silva Pedro Igor Silva
Profile icon Pedro Igor Silva
View More author details

Table of Contents (18) Chapters

Preface 1. Getting Started with Keycloak 2. Securing Your First Application 3. Brief Introduction to Standards 4. Authenticating Users with OpenID Connect 5. Authorizing Access with OAuth 2.0 6. Securing Different Application Types 7. Integrating Applications with Keycloak 8. Authorization Strategies 9. Configuring Keycloak for Production 10. Managing Users 11. Authenticating Users 12. Managing Tokens and Sessions 13. Extending Keycloak 14. Securing Keycloak and Applications 15. Assessments 16. Other Books You May Enjoy
17. Index

Securely invoking the backend REST API

Now, open http://localhost:3000/ and click on the Public endpoint link. You will see a message saying Public message!. The public endpoint is not secured by Keycloak and can be invoked without an access token.

Next, let’s try the secured endpoint that is protected by Keycloak. Open http://localhost:3000/ again. This time, click on the Secured endpoint link. Now you will see a message saying Access denied. This request is not permitted since it requires a valid access token to invoke the endpoint.

Let’s now try to invoke the secured endpoint from the frontend. Open http://localhost:8000/ and click on Invoke Service. You will now see a message displayed saying Secret message!. If instead you get the message Access Denied, this is most likely caused by the user not having the myrole role.

When you click Invoke Service, the frontend sends an AJAX request to the backend service, including the access token in the request, which allows the backend to verify that the invocation is done on behalf of a user who has the required role to access the endpoint.

You have been reading a chapter from
Keycloak - Identity and Access Management for Modern Applications - Second Edition
Published in: Jul 2023 Publisher: Packt ISBN-13: 9781804616444
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}