Code Monkey home page Code Monkey logo

sample-dhp-challenge-api's Introduction

sample-dhp-challenge-api

Provides authentication/authorization as well as identity verification

Implementation notes

  • generateToken will be used for authenticating. Clients will provide their AppID username, and password and get back a token that includes the scopes to which they have acces. (decided on 2020/08/04)
  • Caching will be delegated to dhp-cache-lib (decided on 2020/08/04)
  • Logging will be delegated to dhp-logging-lib (decided on 2020/08/04)
  • HTTP calls will be delegated to dhp-http-lib (decided on 2020/08/04)
  • jose will be used for JWS verification (decided on 2020/08/04)

Operation details

generateToken

Flow

  1. Client invokes generateToken, passing username, and password
  2. API will resolve the appid_client_id and appid_client_secret using environment variables (inherited from the cluster)
  3. API will invoke the "login" operation on App ID
  4. API will return the response, transforming it to comply with the API specification

generateIdentityChallenge

Flow

  1. Client invokes generateIdentityChallenge, passing a token from generateToken in the Authorization header, and optionally providing public_key in the request body. public_key represents the psuedonym of the user (i.e. Holder or Employee) which is present in all verifiable credentials that are issued to users.
  2. API will generate a random string (nonce) and cache the association the nonce and the public_key from Step 1. If public_key is not provided, the nonce should be specified as both the cache key and value. The cache entry should expire after 1 minute (this should be configurable via process.env)
  3. API will return the challenge response, per the API specification

verifyIdentity

Flow

  1. Client invokes verifyIdentity, passing a token from generateToken in the Authorization header, providing public_key and signature in the request body. signature is a JSON Web Signature (JWS) and represents the hash of the challenge of a response from generateIdentityChallenge
  2. API validates the signature, using public_key (see https://github.com/panva/jose/blob/HEAD/docs/README.md#jwsverifyjws-keyorstore-options)
  3. If the signature is valid, API extracts the nonce from the payload and find a matching cache entry for public_key and the nonce.
  4. If a match is found, API sets verified to true in the response body

Deployment

AppID scopes & roles

The following scopes should be configured in AppID:

  • gen_id_challenge
  • verify_identity

Following is the default roles created in AppID instance, during deployment:

  • challenge-admin
    • with scopes: gen_id_challenge, verify_identity

A user with above role should be onboarded to use this api.

Environment Variables

The environment variables support - and in some cases expected - by the component. An environment variable that is marked required but not available to the component will result in the component not starting.

Name Required Description
APP_ID_OAUTH_SERVER_URL yes AppID oauth url used to generate access tokens
APP_ID_CLIENT_ID yes AppID application clientID
APP_ID_SECRET yes AppID application secret
OAUTH_TOKEN_VERIFICATION_URL yes AppID verification/introspect endpoint
OAUTH_SERVICE_CLIENT_ID yes AppID service clientID
OAUTH_SERVICE_CLIENT_SECRET yes AppID service secret
CACHE_TTL yes Used to set default caching period

sample-dhp-challenge-api's People

Contributors

opendhp avatar

Watchers

Sijo Cherian avatar Bonnie Ishiguro avatar Pravesh Patel avatar Alan O'Neill avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.