Skip to content

BioID Wrapper #4

@OR13

Description

@OR13

Implement an express wrapper using:

// https://www.npmjs.com/package/openid-client
// https://github.com/panva/node-openid-client

const Issuer = require('openid-client').Issuer;

var client;

Issuer.discover('https://account.bioid.com/connect/.well-known/openid-configuration')
    .then((bioIdIssuer) => {
        console.log('Discovered bioIdIssuer %s', bioIdIssuer);
        var client_id = 'CLIENT_ID';
        var client_secret = 'CLIENT_SECRET'
        client = new bioIdIssuer.Client({
            client_id: client_id,
            client_secret: client_secret
        });
    });

app.get('/api/v0/bioid/login', (req, res) => {
    // after authenticating user will be redirected to /callback
    var url = client.authorizationUrl({
        redirect_uri: 'http://ti-acs-swarmagents.southcentralus.cloudapp.azure.com:8080/callback',
        scope: 'openid',
    });
    res.redirect(url);
});

app.get('/callback', (req, res) => {
    // req.query === .../callback?code=XXX
    client.authorizationCallback('http://ti-acs-swarmagents.southcentralus.cloudapp.azure.com:8080/callback',  req.query)
        .then((tokenSet) => {
            console.log('received and validated tokens %j', tokenSet);
            console.log('validated id_token claims %j', tokenSet.claims);
            // Here we return the token set for the BioId OpenId Connect User.
            res.json({
                tokenSet: tokenSet
            });
        });
});

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions