An open API service indexing awesome lists of open source software.

https://github.com/oada/oada-client-discovery-js

OADA client discovery middleware
https://github.com/oada/oada-client-discovery-js

Last synced: 12 months ago
JSON representation

OADA client discovery middleware

Awesome Lists containing this project

README

          

* This repository is deprecated. CLient discovery is no longer an OADA protocol. *

[![Build Status](https://travis-ci.org/OADA/oada-client-discovery-js.svg)](https://travis-ci.org/OADA/oada-client-discovery-js)
[![Coverage Status](https://coveralls.io/repos/OADA/oada-client-discovery-js/badge.png?branch=master)](https://coveralls.io/r/OADA/oada-client-discovery-js?branch=master)
[![Dependency Status](https://david-dm.org/oada/oada-client-discovery-js.svg)](https://david-dm.org/oada/oada-client-discovery-js)
[![License](http://img.shields.io/:license-Apache%202.0-green.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

# oada-client-discovery-js
Connect style middleware for OADA (openag.io) client discovery.

## Getting Started

### Installation ###
The library can be installed with `npm` using
```sh
$ npm install oada-client-discovery
```

### Running the Examples ###

#### Minimal Example ##

See [examples README](examples/README.md)

### Running the tests, coverage, and style checks ###
The libraries test can be ran with:
```sh
$ npm test
```

The coverage report is generated by:
```sh
$ npm run cover
```

Gulp runs `jshint` (lint) and `jscs` (style) with:
```sh
$ gulp lint
$ gulp style
```

## API

### clientDiscovery(lookup, options) ###
Connect style middleware for [OADA][oada-docs] client discovery.

To eliminate a dependency on any particular storage system or database a
`lookup` function that fetches client registrations must be provided by the
caller.

[CORS][cors] is required by OADA client discovery and therefore automatically
enabled. See [node-cors][node-cors].

#### Parameters ####
`lookup` {Function} that resolves a client registration from a client ID. It
takes the form `function(lookup, callback)`.

`options` {Object, *Optional*} possibly containing the following properties:

* `cors` {Object} Options object for [node-cors][node-cors]. *Default: {}*

#### Client Registration Object ####
An OADA client registration is a JSON document with at least the following
properties:

* `clientId` {String} client ID
* `redirectUrls` {Array of Strings} Array of allowable OAuth 2.0 redirect URLs.
* `licenses` {Array of Strings} Array of license names the client developer has
agreed to.
* `keys` {[JSON Web Key (JWK) Set][jwks]} containing the client's JWKs for use
with OADA specific OAuth 2.0/OpenID Connect client secrets.

##### Example Client Registration #####
```json
{
"clientId": "123abc@agcloud.com",
"redirectUrls": [
"https://agcloud.com/redirect"
],
"licenses": [
"oada",
],
"keys": [
{
"kty": "RSA",
"use": "sig",
"alg": "RS256",
"kid": "ad8alkjca38afvudsZA",
"n": "AOtWalmH3vZ2q2Be ... SRQjYzxqpyVR9HEJYJ",
"e": "AQAB",
}
]
}
```

#### Usage Example ####
```javascript
var express = require('express');
var clientDiscovery = require('oada-client-discovery');

var app = express();

app.get('/clientDiscovery', clientDiscovery(
function(clientId, cb) {
clients.find({clientId: clientId}, function(err, clients) {
if(err) { return cb(err); }

cb(null, clients[0]);
})
}));
```

[oada-docs]: http://github.com/OADA/oada-docs
[cors]: http://www.w3.org/TR/cors/
[node-cors]: https://github.com/troygoode/node-cors
[jwks]: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33#section-5