Skip to content

Latest commit

 

History

History
83 lines (57 loc) · 4.76 KB

tutorial-authenticate-client-with-gateway.md

File metadata and controls

83 lines (57 loc) · 4.76 KB
title description author ms.service ms.topic ms.date ms.author ms.custom
Tutorial - Authenticate client with Spring Cloud Gateway on Azure Spring Apps
Learn how to authenticate client with Spring Cloud Gateway on Azure Spring Apps.
KarlErickson
spring-apps
tutorial
08/31/2023
v-shilichen
devx-track-java, devx-track-extended-java, mode-other, engagement-fy23

Tutorial: Authenticate client with Spring Cloud Gateway on Azure Spring Apps

Note

The first 50 vCPU hours and 100 GB hours of memory are free each month. For more information, see Price Reduction - Azure Spring Apps does more, costs less! on the Apps on Azure Blog.

Note

Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.

This article applies to: ✔️ Standard consumption and dedicated (Preview)

This quickstart shows you how to secure communication between a client application and a microservice application that is hosted on Azure Spring Apps and shielded with a Spring Cloud Gateway app. The client application is verified as a security principal to initiate contact with the microservice deployed on Azure Spring Apps, using the app built with Spring Cloud Gateway. This method employs Spring Cloud Gateway's Token Relay and Spring Security's Resource Server features for the processes of authentication and authorization, realized through the execution of the OAuth 2.0 client credentials flow.

The following list shows the composition of the sample project:

  • Books SPA: This Single Page Application (SPA), hosted locally, interacts with the Books microservice for adding or searching for books.
  • Books microservice:
    • A Spring Cloud Gateway app hosted in Azure Spring Apps. This app operates as a gateway to the Books RESTful APIs.
    • A Spring Boot RESTful API app hosted in Azure Spring Apps. This app stores the book information in an H2 database. The Books service exposes two REST endpoints to write and read books.

1. Prerequisites

[!INCLUDE deploy-rest-api-app-with-basic-standard-plan]

5. Validate the app

You can access the Books SPA app that communicates with the Books RESTful APIs through the gateway-service app.

  1. Go to http://localhost:3000 in your browser to access the application.

  2. Enter values for Author and Title, and then select Add Book. You see a response similar to the following example:

    Book added successfully: {"id":1,"author":"Jeff Black","title":"Spring In Action"}
    

[!INCLUDE clean-up-resources]

7. Next steps

[!div class="nextstepaction"] Structured application log for Azure Spring Apps

[!div class="nextstepaction"] Map an existing custom domain to Azure Spring Apps

[!div class="nextstepaction"] Set up Azure Spring Apps CI/CD with GitHub Actions

[!div class="nextstepaction"] Set up Azure Spring Apps CI/CD with Azure DevOps

[!div class="nextstepaction"] Use managed identities for applications in Azure Spring Apps

[!div class="nextstepaction"] Run microservice apps (Pet Clinic)

[!div class="nextstepaction"] Run polyglot apps on Enterprise plan (ACME Fitness Store)

For more information, see the following articles: