Skip to content

Demo of Apollo Federation with Keycloak as identity and access management

License

Notifications You must be signed in to change notification settings

dijbi/apollofederation-keycloak-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apollo Federation with Keycloak Demo

This repository is a demo of using Apollo Federation to build a single schema on top of multiple services base from apollographql/federation-demo repo. The microservices are located under the ./services folder and the gateway that composes the overall schema is in the gateway.js file and secure it with Keycloak.

Prerequisites

  • Docker and docker-compose installed
  • Node.js and Yarn installed

Start by cloning this repo.

git clone https://github.com/ilmimris/apollofederation-keycloak-demo/

Then start a Keycloak server using docker-compose.

cd config && docker-compose up

Now in a separate terminal, seed the keycloak server with a sample configuration.

$ yarn keycloak:seed

creating role admin
creating role developer
creating client role admin for client keycloak-connect-graphql-bearer
creating client role developer for client keycloak-connect-graphql-bearer
creating client role admin for client keycloak-connect-graphql-public
creating client role developer for client keycloak-connect-graphql-public
creating user developer with password developer
assigning client and realm roles called "developer" to user developer
creating user admin with password admin
assigning client and realm roles called "admin" to user admin
done

This creates a sample realm called keycloak-connect-graphql with some clients, roles and users that we can use in the examples. Now we are ready to start and explore the examples.

The Keycloak console is accessible at localhost:8080 and the admin login is admin/admin. You can make any configuration changes you wish and npm run examples:seed will always recreate the example realm from scratch.

Installation

To run this demo locally, run the following commands:

yarn install

This will install all of the dependencies for the gateway and each underlying service.

yarn start-services

This command will run all of the microservices at once. They can be found at http://localhost:4001, http://localhost:4002, http://localhost:4003, and http://localhost:4004.

In another terminal window, run the gateway by running this command:

yarn start-gateway

This will start up the gateway and serve it at http://localhost:4000

What is this?

This demo showcases four partial schemas running as federated microservices secured with Keycloak. Each of these schemas can be accessed on their own and form a partial shape of an overall schema. The gateway fetches the service capabilities from the running services to create an overall composed schema which can be queried and the gateway pass the keycloak authentication token to the running services.

To learn more about Apollo Federation, check out the docs

About

Demo of Apollo Federation with Keycloak as identity and access management

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%