How to use the @feathersjs/authentication function in @feathersjs/authentication

To help you get started, we’ve selected a few @feathersjs/authentication examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathers-plus / generator-feathers-plus / test-expands / a-gens / ts / test-service.test-expected / src1 / authentication.ts View on Github external
let moduleExports = function (app: App) {
  const config = app.get('authentication');
  // !code: func_init // !end

  // Set up authentication with the secret
  app.configure(authentication(config));
  app.configure(jwt());
  app.configure(local());
  // !code: loc_1 // !end

  app.configure(oauth2(Object.assign({
    name: 'auth0',
    Strategy: Auth0Strategy,
    // !code: auth0_options // !end
  }, config.auth0)));

  app.configure(oauth2(Object.assign({
    name: 'google',
    Strategy: GoogleStrategy,
    // !code: google_options // !end
  }, config.google)));
github feathers-plus / generator-feathers-plus / examples / ts / 05-secret / feathers-app / src / authentication.ts View on Github external
let moduleExports = function (app: App) {
  const config = app.get('authentication');

  // Set up authentication with the secret
  app.configure(authentication(config));
  app.configure(jwt());
  app.configure(local());
  // !code: loc_1 // !end

  app.configure(oauth2(Object.assign({
    name: 'auth0',
    Strategy: Auth0Strategy
  }, config.auth0)));

  app.configure(oauth2(Object.assign({
    name: 'google',
    Strategy: GoogleStrategy
  }, config.google)));

  app.configure(oauth2(Object.assign({
    name: 'facebook',
github nesterow / frontless / components / server.js View on Github external
app.configure(socketio({}, function(io) {

  io.origins(corsResolver)
  
  io.use(function(socket, next) {
    sessionMiddleware(socket.request, socket.request.res, next)
  })
  
  io.use(function(socket, next) {
    socket.feathers.request = socket.request
    next()
  })

}))

app.configure(authentication({
  session: true,
  secret: REST_AUTH_SECRET || 'secret',
  service: REST_AUTH_SERVICE || 'users',
  cookie: {
    enabled: true,
    name: COOKIE_NAME,
    httpOnly: false,
    secure: false
  },
  jwt: {
    header: { typ: 'access' },
    audience: ORIGIN,
    subject: 'authentication',
    issuer: 'frontless',
    algorithm: 'HS256',
    expiresIn: '10d' // the access token expiry
github nesterow / frontless / lib / server.js View on Github external
app.use(express.json());
  app.use(express.urlencoded({extended: true}));
  app.configure(express.rest());
  app.configure(socketio({}, function(io) {
    // io.use(function(socket, next) {
    //   corsMiddleware(socket.request, socket.request.res, next);
    // });
    io.use(function(socket, next) {
      sessionMiddleware(socket.request, socket.request.res, next);
    });
    io.use(function(socket, next) {
      socket.feathers.request = socket.request;
      next();
    });
  }));
  app.configure(authentication({
    session: true,
    secret: process.env.REST_AUTH_SECRET,
    service: process.env.REST_AUTH_SERVICE,
  }));
  app.configure(local());

  configure(app, express);
  app.use('/*', FrontLessMidleware);
  services(app);
  return app;
};
github nesterow / frontless / src / lib / server / index.js View on Github external
app.use(cors());
app.use(sessionMiddleware);
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.configure(express.rest());
app.configure(socketio({}, function(io) {
  io.use(function(socket, next) {
    sessionMiddleware(socket.request, socket.request.res, next);
  });
  io.use(function(socket, next) {
    socket.feathers.request = socket.request;
    next();
  });
}));
app.configure(authentication({
  session: true,
  secret: '123sd234sdfsdf',
  service: 'users',
}));
app.configure(local());


/**
 * FrontLess express middleware.
 * Provides methods for parsing frontless HTTP requests and valid responces
 * @param {Object} req - express request
 * @param {Object} res - express response
 * @param {Function} next - express callback
 * @async
 */
export async function FrontLessMidleware(req, res, next) {
github nesterow / frontless / src / server.js View on Github external
io.use(function(socket, next) {
    socket.feathers.request = socket.request;
    next();
  })
}))


app.use('/assets', express.static('assets'))
app.use(corsMiddleware)
app.use(sessionMiddleware)
app.use(express.json())
app.use(express.urlencoded({extended: true}))

app.configure(express.rest())

app.configure(authentication({
  session: true,
  secret: process.env.REST_AUTH_SECRET,
  service: process.env.REST_AUTH_SERVICE,
}))

app.configure(local())

app.use(function (req, res, next) {
 
  if ('EIO' in req.query)
    return next();
  if (req.headers.accept &&
      req.headers.accept.includes('/json')) {
    return next();
  }
  if (req.feathers &&