Sign inSign up

qlik/simple-auth-svc

By qlik

Updated over 3 years ago

Simple Auth Service

Image
0

1.4K

qlik/simple-auth-svc repository overview

Simple Auth Service

** This is just an example **

Very simple authentication service that could be used for lightweight testing.

Running the service

  • Build the docker Image
make build
  • Start a container
make run
  • Destroy the container
make tear-down

Using client_credentials token with elastic

  • Send request with client credentials:
curl -X POST \
  http://localhost:8080/token \
  -u 'myClientId:myClientSecret' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d grant_type=client_credentials

Typical response:

200 OK
Content-Type: application/json
{
    "access_token": "{access_token}",
    "token_type": "Bearer",
    "expires_in": 3600
}
  • Send request to elastic:
curl -X GET \
  https://elastic.example/api/v1/collections \
  -H 'Authorization: Bearer {access_token}'

Using an access_token with elastic

This example service takes a base64 encoded user information object and returns it as the /userinfo request

  • Create a userinfo object, ex:
{
  "sub": "test-user-1",
  "name": "test user 1",
  "email": "[email protected]",
  "groups": [
    "Sales",
    "HR"
  ]
}

It MUST include sub , all other claims are optional but recommended.

  • Encode userinfo:
USER_INFO=.$(base64 userinfo.json)
  • Send a request to elastic
curl -k -L -X GET \
  https://elastic.example/api/v1/users/me \
  -H "Authorization: Bearer $USER_INFO"

Typical response:

{
  "id": "Np7UKeHAK4uszngl0Qfd6ODN0YG4zF4W",
  "name": "test user 1",
  "subject": "simple\\test-user-1",
  "tenantId": "_Rz1P3UJ6HoDcDRURz-69kqbTvPPyml5",
  "created": "2018-07-13T03:34:40.506Z",
  "lastUpdated": "2018-07-13T03:34:40.506Z",
  "jwtClaims": {
    "userId": "Np7UKeHAK4uszngl0Qfd6ODN0YG4zF4W",
    "tenantId": "_Rz1P3UJ6HoDcDRURz-69kqbTvPPyml5",
    "subType": "user",
    "sub": "simple\\test-user-1",
    "groups": [
      "Sales",
      "HR",
      "Everyone"
    ]
  },
  "links": {
    "self": {
      "href": "https://elastic.example:443/api/v1/users/Np7UKeHAK4uszngl0Qfd6ODN0YG4zF4W"
    }
  }
}

Deploy to heroku

Create and deploy app
  • Create the app and get its name:
export APP_NAME=$(heroku apps:create --json | jq -r '.name')
  • Build the docker Image
make build
  • Login to heroku registry
heroku container:login
  • Tag image to be deployed to heroku
docker tag qlik/simple-auth-svc:latest registry.heroku.com/$APP_NAME/web
  • Push the docker image to heroku, it will start automatically
docker push registry.heroku.com/$APP_NAME/web
  • Release the image for deployment:
heroku container:release web --app $APP_NAME
Configure your deployment
  • Get the discovery url:
echo https://$APP_NAME.herokuapp.com/.well-known/openid-configuration
  • Update your values.yaml file, using the url from the previous step:
edge-auth:
  secrets:
    idpConfigs:
      - discoveryUrl: "Use url from previous step"
        clientId: "none"
        clientSecret: "none"
        realm: "simple"
        hostname: "elastic.example"
Clean Up resources

Don't forget to clean up resources once you no longer need the provider:

heroku apps:destroy $APP_NAME --confirm $APP_NAME

Tag summary

Content type

Image

Digest

Size

22.9 MB

Last updated

about 8 years ago

docker pull qlik/simple-auth-svc