Node.js microservice for authorization and authentication using Keycloak.
OpenAPI documentation available at http://localhost:3000/api.
For accessing secured endpoints add your access_token provided to you at login to the Authorization header.
npm install# development
npm run start
# watch mode
npm run start:dev
# production mode
npm run start:prod# unit tests
npm run test
# e2e tests
npm run test:e2e
# test coverage
npm run test:covTo run the app in a docker container, run the following commands.
docker network create cinepik-network
docker build -t cinepik-auth .
docker run -d -t --env-file .env --network cinepik-network -p 3000:3000 cinepik-authTo manually upload the image to Docker Hub, run the following commands.
docker build -t cinepik-auth .
docker tag cinepik-auth:latest <dockerhub_username>/cinepik-auth:latest
docker push <dockerhub_username>/cinepik-auth:latestYou can also setup the application with docker-compose.
docker-compose up
docker-compose downCreate config map for keycloak
kubectl create configmap keycloak-config --from-literal=KEYCLOAK_BASE_URL="http://cinepik-keycloak" --from-literal=KEYCLOAK_CLIENT_ID="nest-auth" --from-literal=KEYCLOAK_PORT=8080 --from-literal=KEYCLOAK_REALM="cinepik"Create secret for keycloak
kubectl create secret generic keycloak-config --from-literal=KEYCLOAK_ADMIN="admin" --from-literal=KEYCLOAK_ADMIN_PASSWORD="<REPLACE_ME>" --from-literal=KEYCLOAK_CLIENT_SECRET="<REPLACE_ME>" --from-literal=KEYCLOAK_REALM_RSA_PUBLIC_KEY="<REPLACE_ME>"Apply deployment
kubectl apply -f k8s/cinepik-auth.ymlApply service
kubectl apply -f k8s/cinepik-auth-svc.ymlkubectl get pods
kubectl delete deployment cinepik-auth-deployment
kubectl delete configmap <configmap name>
kubectl rollout restart deployment/cinepik-auth-deployment
kubectl logs <pod-id>
kubectl describe secret <secret-name>
kubectl get secret <secret-name>
kubectl get service
kubectl describe pods