This project demonstrates a simple OAuth 2.0 flow, including an Authorization Server, Resource Server, and Client Server. It allows you to authenticate using OAuth 2.0, check access tokens, and access protected resources through the Resource Server.
- auth-server: The Authorization Server responsible for issuing tokens.
- resource-server: The Resource Server responsible for serving protected resources.
- client-server: The Client Server that interacts with the Authorization Server to get the access token and access protected resources.
-
Clone the repository:
git clone https://github.com/NORT0X/OAuth2.0.git cd OAuth2.0
-
Build and run the Docker containers:
docker-compose up --build
This will build the images for the Authorization Server, Resource Server, and Client Server and start them in separate containers.
To bring down the containers:
docker-compose down
-
Send a GET request to localhost:8081/login?username=test to initiate the authentication and obtain the access token:
curl -X GET "http://localhost:8081/login?username=test"
-
Finally, use the obtained access token to access a protected resource from the Resource Server. Replace <access_token> with the actual token you received:
curl -X GET "http://localhost:8081/resource/get" \ -H "Authorization: Bearer <access_token>"