Skip to content
This repository has been archived by the owner on May 29, 2021. It is now read-only.

scootr-it/scootr-spid

Repository files navigation

scootr SPID

Deployment

scootr's service to handle SPID authentication.

Set up

Production

Note
Before setting the custom domain you need to add these DNS records

  • CNAME:
    • Name: Your custom domain (e.g.: spid.scootr.it.)
    • Value: Your Azure App Service URL (e.g.: scootr.azurewebsites.net.)
  • TXT:
    • Name: Your custom domain with the asuid subdomain (e.g.: asuid.spid.scootr.it.)
    • Value: Your Custom Domain Verification ID (App Service -> Settings -> Custom Domains)

Service Provider

  1. Create a resource group
az group create --name scootr --location "West Europe"
  1. Create a Container Registry
az acr create --name scootrregistry --resource-group scootr --sku Basic --admin-enabled true
  1. Retrieve credentials
az acr credential show --resource-group scootr --name scootrregistry
  1. Sign in to the registry
docker login scootrregistry.azurecr.io --username scootrregistry
  1. Build the local image
docker build . -t sp:latest
  1. Tag the local image for the registry
docker tag sp scootrregistry.azurecr.io/sp:latest
  1. Push Service Provider image to the registry
docker push scootrregistry.azurecr.io/sp:latest
  1. Create an App Service plan
az appservice plan create --name scootr-asp --resource-group scootr --sku B1 --is-linux
  1. Create Web App
az webapp create --resource-group scootr --plan scootr-asp --name scootr --deployment-container-image-name scootrregistry.azurecr.io/sp:latest
  1. Add custom domain
az webapp config hostname add --hostname spid.scootr.it --resource-group scootr --webapp-name scootr
  1. Create a managed certificate for the custom domain
az webapp config ssl create --resource-group scootr --name scootr --hostname spid.scootr.it
  1. Bind the SSL certificate to the web app
az webapp config ssl bind --certificate-thumbprint {certificate-thumbprint} --name scootr --resource-group scootr --ssl-type SNI
  1. Set HTTPS Only mode
az webapp update --https-only true --name scootr --resource-group scootr
  1. Add environment settings to the web app
az webapp config appsettings set -g scootr -n scootr --settings ENV="prod"
az webapp config appsettings set -g scootr -n scootr --settings SP_ENTITYID="https://spid.scootr.it"
az webapp config appsettings set -g scootr -n scootr --settings DATABASE_CONNECTION_STRING="host={DB_HOST} port={DB_PORT} dbname={DB_NAME} user={DB_USER} password={DB_PASS}"
az webapp config appsettings set -g scootr -n scootr --settings STRIPE_SECRET_API_KEY="{STRIPE_SECRET_API_KEY}"
az webapp config appsettings set -g scootr -n scootr --settings CLIENT_HOST="https://scootr.it"

Test Identity Provider

Please DO NOT ever do this.
This is just for testing and learning purposes.
I'm also assuming you already followed the previous steps.

  1. Build the local image
docker build . -f Dockerfile.idp.prod -t testidp:latest
  1. Tag the local image for the registry
docker tag testidp scootrregistry.azurecr.io/testidp:latest
  1. Push Test Identity Provider image to the registry
docker push scootrregistry.azurecr.io/testidp:latest
  1. Create Web App
az webapp create --resource-group scootr --plan scootr-asp --name spidtestidp --deployment-container-image-name scootrregistry.azurecr.io/testidp:latest
  1. Add custom domain
az webapp config hostname add --hostname testidp.scootr.it --resource-group scootr --webapp-name spidtestidp
  1. Create a managed certificate for the custom domain
az webapp config ssl create --resource-group scootr --name spidtestidp --hostname testidp.scootr.it
  1. Bind the SSL certificate to the web app
az webapp config ssl bind --certificate-thumbprint {certificate-thumbprint} --name spidtestidp --resource-group scootr --ssl-type SNI
  1. Set HTTPS Only mode
az webapp update --https-only true --name spidtestidp --resource-group scootr