Skip to content

Prevent automatic addition of token endpoint #29

@charwking

Description

@charwking

Is there any interest in supporting some way of disabling the automatic addition of the /token route in order to support usage of restify-oauth2 in multiple servers on the same domain?

My use case is that I'd like to have a restify server running at mydomain.com/api/auth which has a /token route, and then multiple other servers running at other points which do not grant tokens, but use the restify-oauth2 library to validate tokens.

To be more explicit, I'm interested in something like this:

// ====== server running at mydomain.com/api/auth ======

var restify = require('restify'),
   restifyOauth2 = require('restify-oauth2');

// server setup ...

restifyOAuth2.cc(server, {includeTokenEndpoint: true});
server.listen(8080);

// ====== server running at mydomain.com/api/users ======

var restify = require('restify'),
   restifyOauth2 = require('restify-oauth2');

// server setup...

restifyOAuth2.cc(server, {includeTokenEndpoint: false});

server.get('/', function (req, res) {
   if (!req.clientId) {
      return res.sendUnauthenticated();
   }

   res.contentType = 'application/json';
   res.send({message: 'I can tell you got a token from the other server'});
});

server.listen(8090);

If there's interest, I'm happy to work on a pull request. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions