# Sample Application Architecture

## Architecture

We will extend the existing two microservices to use federated authentication based on OAuth 2.1 and OpenID Connect (OIDC).

* **OpenID Connect (OIDC) Identity Provider**: This is central identity provider for single sign on which holds all users with their credentials
* **OAuth2/OIDC Resource Server (product-initial)**: The backend microservice providing product data (the OAuth2/OIDC resource server)
* **OAuth2/OIDC Client (ui-initial)**: The frontend UI microservice consuming the products (the OAuth2/OIDC client)

![Architecture](/files/sZm1ReeDgYe4TcGObaRT)

## Configuration

These microservices are configured to be reachable via the following URL addresses (Port 8080 is the default port in spring boot).

Service URLs:

| Service                        | URL                            |
| ------------------------------ | ------------------------------ |
| OIDC Identity Provider         | <http://localhost:9000>        |
| Client (UI)                    | <http://localhost:9095/client> |
| Resource Server (Products API) | <http://localhost:9090/server> |

## Project contents

After importing the project into your IDE you should see a project structure like in the following picture. Here the VS Code project is shown, it may look different in other IDE's.

![Project Structure](/files/K2BbpUAxVsYTQ2TpKkk9)

The main contents for this workshop consist of the following directories:

* **intro-labs**: In the sub-directory *auth-code-in-action* you find a demo application that illustrates the OAuth 2 authorization code grant flow in details. Here you can follow all the subsequent steps happening during this protocol flow variant.\
  In the sub-directory *oauth\_grants* you get instructions on how to try different OAuth 2 authorization grant flows yourself with different tools like *postman*, *curl* and *httpie*.
* **labs**: In this directory you find the workshop lab parts.
  * initial: This will be the starting point to implement code as part of this workshop
    * product: This is the provided sample product server microservice
    * ui: This is the provided sample product ui client microservice
  * solution: This is the reference solution for this workshop (please do NOT look into this now)
    * product: This is the reference solution of a OAuth2/OIDC product server microservice
    * ui: This is the reference solution of a OAuth2/OIDC product ui client microservice

> **Info:** You can find more information on building OAuth 2.0/OIDC secured microservices with spring in [Spring Boot Reference Documentation](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-security-oauth2) and in [Spring Security Reference Documentation](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2)

So let's start with implementing the server side: The API (resource server).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andifalk.gitbook.io/oauth-2.1-and-openid-connect-for-java-developers/introduction/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
