Giter VIP home page Giter VIP logo

auth-service's Introduction

Auth Service (Work in Progress)

Git Commit Git Releases Npm Version NPM Vulnerabilities CircleCI

Mojaloop central AuthZ + AuthN service. Currently for FIDO implementation in a Mojaloop switch.

Overview

Setup

Clone repo

git clone [email protected]:mojaloop/AuthService.git

Improve local DNS resolver

Add the 127.0.0.1 auth-service.local entry in your /etc/hosts so the auth-service is reachable on http://auth-service.local:4004. Elsewhere use http://localhost:4004

Install service dependencies

cd auth-service
npm ci

Run local dockerized auth-service

npm run docker:build
npm run docker:run

To check the auth-service health visit http://auth-service.local:4004/health

Run locally with database in docker-compose

docker-compose up -d mysql
npm run migrate
npm run start

Updating the OpenApi (Swagger) Spec

We use multi-file-swagger to make our swagger files more manageable.

After making changes to the .yaml files in ./src/interface/, update the swagger.json file like so:

    npm run build:openapi

Note: We will likely want to move to swagger 3.0 at some point, and once we do, we will be able to use the common api snippets library to factor out common Mojaloop snippets. Keep track of #352 - Update to OpenAPI v3

Auditing Dependencies

We use audit-ci along with npm audit to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an audit-ci.jsonc file.

To start a new resolution process, run:

npm run audit:fix

You can then check to see if the CI will pass based on the current dependencies with:

npm run audit:check

The audit-ci.jsonc contains any audit-exceptions that cannot be fixed to ensure that CircleCI will build correctly.

auth-service's People

Contributors

akapur99 avatar dependabot[bot] avatar eoln avatar kleyow avatar lewisdaly avatar oderayi avatar ramanmangla avatar spikerheado1234 avatar sridharvoruganti avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auth-service's Issues

Consolidate Error Library

If we're introducing error libraries - as per #41, we shouldn't have separate libraries for domain/model/handler. A single error library might be more useful to call from across the auth-service.
As per discussion with @lewisdaly

webauthn assertion

@Lewis Daly @kevin Leyow @sam @michael Richards @JJ Geewax
I am preparing some changes in PISP API to be compatible for webauthn based assertion (attestation for credential registration in linking flow is already done)

Starting from client webauthn api https://webauthn.guide/#authentication

The problem which I see is that there is a need to pass allowCredentials structure in navigator.credentials.get call. From docs it comes out that server should be responsible to generate allowCredentials entries to enforce using already registered credential and transports

Are we expecting auth-service will do it or pisp-demo/client -> but still credentialId should be used as part of payload for POST /thirdpartyRequests/authorization ? I suggest to add credentialId and transports fields as a part of payload: https://github.com/mojaloop/api-snippets/blob/master/thirdparty/openapi3/components/schemas/ThirdpartyRequestsAuthorizationsPostRequest.yaml

  1. Passing assertion for verification to auth-service via PUT /thirdpartyRequests/authorizations/ID Assertion has structure PublicKeyCredential which is quite complex and differs a lot from U2FPinValue we already have defined: https://github.com/mojaloop/api-snippets/blob/master/thirdparty/openapi3/components/schemas/U2FPinValue.yaml

I suggest replacing U2FPinValue with PublicKeyCredential so all necessary for assertion parameters can be delivered to auth-service.

Missing endpoint configuration

In config.ts, there is no way to configure the endpoints that get passed through to the sdk-standard-components (see here).

We need to expose these configuration options so that the auth-service can talk to the switch.

pattern for returning status codes: 400 vs 404 vs 422

@MichaelJBRichards @jgeewax @lewisdaly @bushjames @elnyry-sam-k

We need to agree on the pattern of how we should return HTTP status codes when doing validation of complex requests. For example in POST /thirdpartyRequests/transactions/{ID}/authorizations we have request payload body defined as

export interface AuthPayload {
  consentId: string;
  sourceAccountId: string;
  status: 'PENDING' | 'VERIFIED';
  challenge: string;
  value: string;
}

the code: https://github.com/mojaloop/auth-service/pull/22/files#diff-7da2816b4c61411199493eb4e1667117

we already have payload validated according open-api specification and if needed 400 (Bad Request) status code is return
and we are doing some domain-specific semantic validations, like

  • if Consent for givenconsentId has the proper status
  • if there are matching Scopes for Consent

here the question arises: should we return 404 (Not Found) if there is nothing in our store or 400 (Bad Request),
or maybe 422 (Unprocessable entity) because we have valid request body - open-api schema validation is successful, so Bad Request is not applicable because there is no syntax error.
404 is also not applicable - it should be used when the server has not found anything matching the Request-URI - and the URI is valid.

PROPOSED Pattern:
400 (BadReqeust) only for request syntax errors
404 (Not Found) when the Request-URI is invalid and also if any resource referenced by URL parameter can't be found in store
422 (Unprocessable entity) when semantic validation fails: any resource referenced in payload body can't be found or can't be used to fulfill the request (not enough data properties, not expected internal state not found related entities and so on)

I am assigning the issue to @MichaelJBRichards because he is a member of the API control board and I believe this decision should get approval from the board.

Improve Test Readability + Add Tests for Unlinking Flow + Consolidate Mocked Resources

There is a need to improve test readability across auth-service to make it more clear.
Additionally, more tests are needed for the following cases:

  • Where generatePatchConsentRequest is called with ACTIVE Consent argument
  • Where revokeConsentStatus is called with REVOKED Consent argument
  • Seed with data with REVOKED consent status + add tests for revoke related logic'

Furthermore, we want to create a central data file for all mocked resources used in unit tests.

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.