-
Config service: This service is responsible for providing the configuration to other services. It is a centralized configuration service.
- URL:
http://localhost:8888/
- URL:
-
Registry service: This service is responsible for service discovery and registration of services. It is a Eureka server.
- URL:
http://localhost:8761/
- URL:
-
Gateway service: This service is responsible for routing the requests to the appropriate service.
- URL:
http://localhost:8080/
- URL:
-
User service: This service is responsible for user management. Also, it provides the APIs for user registration, login, logout, etc.
- URL:
http://localhost:8090/
- URL:
- Config service
- Registry service
- Admin service
- Gateway service
- the other services...
- Search with process use a specific port:
- Windows:
netstat -aon | findstr [port]
- Windows:
- Kill a process by PID:
- Windows:
taskkill /F /PID [pid]
- Windows:
NOTE: The Keycloak server is used to provide the authentication and authorization services (Authorization Server)
- Start Keycloak server: With docker-compose or
docker run -p 9090:8080 -e KEYCLOAK_ADMIN=<username> -e KEYCLOAK_ADMIN_PASSWORD=<password> quay.io/keycloak/keycloak:24.0.4 start-dev - Create a realm (tenant): Use the app name
- Create a client:
- In the input "Client ID" set: -client
- Enable the "Client authentication" option that is AccessType=confidential
- In "Valid redirect URIs" input set
http://localhost:<gateway-port>/login/oauth2/code/<client-id>, that is the URL where the client is going to be redirected after a successful login - In "Web Origins" input set:
*
- Create a user
NOTE: The services are going to be the Resource Server, that is the service that is going to validate the JWT token.
- Add the dependencies:
<dependencies> ... <!--START KEYCLOAK DEPENDENCIES--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-oauth2-resource-server</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-jose</artifactId> </dependency> <!--END KEYCLOAK DEPENDENCIES--> ... </dependencies>
- Add the Keycloak configuration in the
application.ymlfile:- The issuer-uri can be found in the Keycloak server in:
Realm Settings/Endpoints/OpenID Endpoint Configuration
spring: security: oauth2: resourceserver: jwt: issuer-uri: http://localhost:9090/realms/<realm-name>
- The issuer-uri can be found in the Keycloak server in:
