Skip to content

smathangi/service-auth-provider-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Service auth provider

Build Status Codacy Badge codecov

This microservice is used to authenticate services across HMCTS.

Getting Started

Prerequisites

Building

To build the project execute the following command:

$ ./gradlew build

Configuration

In order to setup Service Auth Provider to work with a client service, you need to do the following:

  • In the Azure Key Vault named s2s-{environment} add the service's secret used for generating OTPs (one-time passwords). This has to be done in each environment the service is going to be deployed to. Service Auth Provider will use that secret for validating OTPs. It has to be a BASE32-encoded sequence of ten random bytes (16 characters after encoding). By convention, the Azure Key Vault secret's name should follow this format: microservicekey-{service-name}. Here's how to generate it.
  • Add the client service to local.microservice_key_names map in main.tf. The key has to be the service name (as in HTTP requests) and the value must be the name of the Azure Key Vault secret created in the previous step. For example, service named test_service would be configured like this:
  microservice_key_names = {
    ...
    "TEST_SERVICE" = "microservicekey-test-service"
    ...
  }

Generating the microservice secret

Here's a sample Java snippet to generate a microservice secret:

byte[] bytes = new byte[10];
SecureRandom.getInstanceStrong().nextBytes(bytes);
String secret = new Base32().encodeAsString(bytes);

Sample Python code to generate that secret:

import os
import base64
base64.b32encode(os.urandom(10))

Running

To run the app execute:

$ ./gradlew bootRun

You can also run the app on docker.
To build:

$ docker-compose build

And to run:

$ docker-compose up

Dockerized app comes with preconfigured sample service. See docker-compose.yml for details.

Documentation

API documentation is provided with Swagger.
Json spec is available under standard /v2/api-docs route.

Flow diagram can be found here

Developing

Unit tests

To run all unit tests execute the following command:

$ ./gradlew test

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Service to Service Authorisation Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 80.3%
  • HCL 16.7%
  • Groovy 2.8%
  • Dockerfile 0.2%