Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Move to npm scope #594

Merged
merged 1 commit into from Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions README.md
@@ -1,17 +1,15 @@
# feathers-authentication
# @feathersjs/authentication

[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/authentication.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/feathersjs/authentication.png?branch=master)](https://travis-ci.org/feathersjs/authentication)
[![Maintainability](https://api.codeclimate.com/v1/badges/65abe50ec85244072ee9/maintainability)](https://codeclimate.com/github/feathersjs/authentication/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/65abe50ec85244072ee9/test_coverage)](https://codeclimate.com/github/feathersjs/authentication/test_coverage)
[![Dependency Status](https://img.shields.io/david/feathersjs/authentication.svg?style=flat-square)](https://david-dm.org/feathersjs/authentication)
[![Download Status](https://img.shields.io/npm/dm/feathers-authentication.svg?style=flat-square)](https://www.npmjs.com/package/feathers-authentication)
[![Slack Status](http://slack.feathersjs.com/badge.svg)](http://slack.feathersjs.com)
[![Download Status](https://img.shields.io/npm/dm/feathers-authentication.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication)

> Add Authentication to your FeathersJS app.

`feathers-authentication` adds shared [PassportJS](http://passportjs.org/) authentication for Feathers HTTP REST and WebSocket transports using [JSON Web Tokens](http://jwt.io/).
`@feathersjs/authentication` adds shared [PassportJS](http://passportjs.org/) authentication for Feathers HTTP REST and WebSocket transports using [JSON Web Tokens](http://jwt.io/).


## Installation
Expand All @@ -37,7 +35,7 @@ This module contains:

### Hooks

`feathers-authentication` only includes a single hook. This bundled `authenticate` hook is used to register an array of one or more authentication strategies on a service method.
`@feathersjs/authentication` only includes a single hook. This bundled `authenticate` hook is used to register an array of one or more authentication strategies on a service method.

> **Note:** Most of the time you should be registering this on your `/authentication` service. Without it you can hit the `authentication` service and generate a JWT `accessToken` without authentication (ie. anonymous authentication).

Expand Down Expand Up @@ -108,19 +106,19 @@ The following default options will be mixed in with your global `auth` object fr

The following plugins are complementary but entirely optional:

- [feathers-authentication-client](https://github.com/feathersjs/feathers-authentication-client)
- [feathers-authentication-local](https://github.com/feathersjs/feathers-authentication-local)
- [feathers-authentication-jwt](https://github.com/feathersjs/feathers-authentication-jwt)
- [feathers-authentication-oauth1](https://github.com/feathersjs/feathers-authentication-oauth1)
- [feathers-authentication-oauth2](https://github.com/feathersjs/feathers-authentication-oauth2)
- [feathers-authentication-hooks](https://github.com/feathersjs/feathers-authentication-hooks)
- [feathers-authentication-client](https://github.com/feathersjs/authentication-client)
- [feathers-authentication-local](https://github.com/feathersjs/authentication-local)
- [feathers-authentication-jwt](https://github.com/feathersjs/authentication-jwt)
- [feathers-authentication-oauth1](https://github.com/feathersjs/authentication-oauth1)
- [feathers-authentication-oauth2](https://github.com/feathersjs/authentication-oauth2)
- [feathers-authentication-hooks](https://github.com/feathersjs/authentication-hooks)
- [feathers-permissions](https://github.com/feathersjs/feathers-permissions)

## Migrating to 1.x
Refer to [the migration guide](./docs/migrating.md).

## Complete Example
Here's an example of a Feathers server that uses `feathers-authentication` for local auth. You can try it out on your own machine by running the [example](./example/).
Here's an example of a Feathers server that uses `@feathersjs/authentication` for local auth. You can try it out on your own machine by running the [example](./example/).

**Note:** This does NOT implement any authorization. Use [feathers-permissions](https://github.com/feathersjs/feathers-permissions) for that.

Expand All @@ -135,7 +133,7 @@ const errors = require('feathers-errors');
const errorHandler = require('feathers-errors/handler');
const local = require('feathers-authentication-local');
const jwt = require('feathers-authentication-jwt');
const auth = require('feathers-authentication');
const auth = require('@feathersjs/authentication');

const app = feathers();
app.configure(rest())
Expand Down
38 changes: 19 additions & 19 deletions docs/migrating.md
Expand Up @@ -8,12 +8,12 @@ We've also decoupled the authentication strategies and permissions from the core

They are now located here:

- [feathers-authentication-client](https://github.com/feathersjs/feathers-authentication-client)
- [feathers-authentication-local](https://github.com/feathersjs/feathers-authentication-local)
- [feathers-authentication-jwt](https://github.com/feathersjs/feathers-authentication-jwt)
- [feathers-authentication-oauth1](https://github.com/feathersjs/feathers-authentication-oauth1)
- [feathers-authentication-oauth2](https://github.com/feathersjs/feathers-authentication-oauth2)
- [feathers-authentication-hooks](https://github.com/feathersjs/feathers-authentication-hooks)
- [feathers-authentication-client](https://github.com/feathersjs/authentication-client)
- [feathers-authentication-local](https://github.com/feathersjs/authentication-local)
- [feathers-authentication-jwt](https://github.com/feathersjs/authentication-jwt)
- [feathers-authentication-oauth1](https://github.com/feathersjs/authentication-oauth1)
- [feathers-authentication-oauth2](https://github.com/feathersjs/authentication-oauth2)
- [feathers-authentication-hooks](https://github.com/feathersjs/authentication-hooks)
- [feathers-permissions](https://github.com/feathersjs/feathers-permissions) **(experimental)**

For most of you, migrating your app should be fairly straight forward as there are only a couple breaking changes to the public interface.
Expand All @@ -27,7 +27,7 @@ For most of you, migrating your app should be fairly straight forward as there a
**The Old Way (< v0.8.0)**

```js
// feathers-authentication < v0.8.0
// @feathersjs/authentication < v0.8.0

// In your config files
{
Expand All @@ -47,7 +47,7 @@ For most of you, migrating your app should be fairly straight forward as there a
}

// In your authentication service
const authentication = require('feathers-authentication');
const authentication = require('@feathersjs/authentication');
const FacebookStrategy = require('passport-facebook').Strategy;

let config = app.get('authentication');
Expand All @@ -59,7 +59,7 @@ app.configure(authentication(config))
**The New Way**

```js
// feathers-authentication >= v1.0.0
// @feathersjs/authentication >= v1.0.0

// In your config files
{
Expand All @@ -74,7 +74,7 @@ app.configure(authentication(config))
}

// In your app or authentication service, wherever you would like
const auth = require('feathers-authentication');
const auth = require('@feathersjs/authentication');
const local = require('feathers-authentication-local');
const jwt = require('feathers-authentication-jwt');
const oauth1 = require('feathers-authentication-oauth1');
Expand Down Expand Up @@ -155,15 +155,15 @@ Authenticating through the Feathers client is almost exactly the same with just

- `type` is now `strategy` when calling `authenticate()` and must be an exact name match of one of your strategies registered server side.
- You must fetch your user explicitly (typically after authentication succeeds)
- You require `feathers-authentication-client` instead of `feathers-authentication/client`
- You require `feathers-authentication-client` instead of `@feathersjs/authentication/client`

You can use `feathers-authentication-compatibility` on the server to keep the old client functional, this helps to migrate large scale deployments where you can not update all clients/api consumers before migrating to `>=1.0.0` Check https://www.npmjs.com/package/feathers-authentication-compatibility for more information.

**The Old Way (< v0.8.0)**

```js
// feathers-authentication < v0.8.0
const auth = require('feathers-authentication/client');
// @feathersjs/authentication < v0.8.0
const auth = require('@feathersjs/authentication/client');
app.configure(auth());

app.authenticate({
Expand Down Expand Up @@ -266,7 +266,7 @@ app.configure(authentication({
}));
```

If you want to customize things further you can refer to the [`feathers-authentication-jwt`](https://github.com/feathersjs/feathers-authentication-jwt) module or implement your own custom passport JWT strategy.
If you want to customize things further you can refer to the [`feathers-authentication-jwt`](https://github.com/feathersjs/authentication-jwt) module or implement your own custom passport JWT strategy.

## Hook Changes

Expand All @@ -282,7 +282,7 @@ For the JWT strategy, this hook has different behavior from the old hooks: it wi

### Removed Hooks

We have removed all of the old authentication hooks. If you still need these they have been moved to the [feathers-authentication-hooks](https://github.com/feathersjs/feathers-authentication-hooks) repo and some of them have been deprecated.
We have removed all of the old authentication hooks. If you still need these they have been moved to the [feathers-authentication-hooks](https://github.com/feathersjs/authentication-hooks) repo and some of them have been deprecated.

The following hooks have been removed:

Expand All @@ -298,9 +298,9 @@ The following hooks have been removed:
Typically you saw a lot of this in your hook definitions for a service:

```js
// feathers-authentication < v0.8.0
// @feathersjs/authentication < v0.8.0
// Users service
const auth = require('feathers-authentication').hooks;
const auth = require('@feathersjs/authentication').hooks;
exports.before = {
all: [],
find: [
Expand Down Expand Up @@ -336,8 +336,8 @@ exports.before = {
**The New Way**

```js
// feathers-authentication >= v1.0.0
const auth = require('feathers-authentication');
// @feathersjs/authentication >= v1.0.0
const auth = require('@feathersjs/authentication');
const local = require('feathers-authentication-local');
const {
queryWithCurrentUser,
Expand Down
10 changes: 5 additions & 5 deletions docs/new-1.0-features.md
Expand Up @@ -25,20 +25,20 @@ app.configure(authentication({
We've added more helpful warning messages and added debug logs for every hook, service, and middleware. We use the [debug]() module so usage is the same.

#### Turning on all auth logs
You can turn on all auth debug logs by running your app with `DEBUG=feathers-authentication* npm start`.
You can turn on all auth debug logs by running your app with `DEBUG=@feathersjs/authentication* npm start`.

#### Turning on logs for a specific type
If you want to only turn on logs for a `hooks`, `express`, `passport` or `service` you can do `DEBUG=feathers-authentication:<type>* npm start`. For example,
If you want to only turn on logs for a `hooks`, `express`, `passport` or `service` you can do `DEBUG=@feathersjs/authentication:<type>* npm start`. For example,

```
`DEBUG=feathers-authentication:hooks* npm start`
`DEBUG=@feathersjs/authentication:hooks* npm start`
```

#### Turning on logs for a specific entity
If you want to only turn on logs for a specific hook, middleware or service you can do `DEBUG=feathers-authentication:<type>:<entity> npm start`. For example,
If you want to only turn on logs for a specific hook, middleware or service you can do `DEBUG=@feathersjs/authentication:<type>:<entity> npm start`. For example,

```
`DEBUG=feathers-authentication:hooks:authenticate npm start`
`DEBUG=@feathersjs/authentication:hooks:authenticate npm start`
```

## More Flexible Tokens
Expand Down
6 changes: 3 additions & 3 deletions example/README.md
@@ -1,6 +1,6 @@
# feathers-authentication Example
# @feathersjs/authentication Example

This provides a complete working example of some of the basic usage of `feathers-authentication`.
This provides a complete working example of some of the basic usage of `@feathersjs/authentication`.

1. Start the app by running `npm start`
2. Make a request using the authenticated user.
Expand All @@ -9,4 +9,4 @@ This provides a complete working example of some of the basic usage of `feathers
curl -H "Content-Type: application/json" -X POST -d '{"email":"admin@feathersjs.com","password":"admin"}' http://localhost:3030/authentication
```

For more details refer to the [`test/integration`](../test/integration) folder to see how you can authenticate with the server or refer to the [feathers-authentication-client](https://github.com/feathersjs/feathers-authentication-client).
For more details refer to the [`test/integration`](../test/integration) folder to see how you can authenticate with the server or refer to the [feathers-authentication-client](https://github.com/feathersjs/authentication-client).
2 changes: 1 addition & 1 deletion lib/express/authenticate.js
@@ -1,6 +1,6 @@
const errors = require('@feathersjs/errors');
const Debug = require('debug');
const debug = Debug('feathers-authentication:express:authenticate');
const debug = Debug('@feathersjs/authentication:express:authenticate');

module.exports = function authenticate (strategy, options = {}) {
// TODO (EK): Support arrays of strategies
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/authenticate.js
@@ -1,7 +1,7 @@
const errors = require('@feathersjs/errors');
const Debug = require('debug');
const merge = require('lodash.merge');
const debug = Debug('feathers-authentication:hooks:authenticate');
const debug = Debug('@feathersjs/authentication:hooks:authenticate');

module.exports = function authenticate (strategies, options = {}) {
if (!strategies) {
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -7,7 +7,7 @@ const getOptions = require('./options');
const service = require('./service');
const socket = require('./socket');

const debug = Debug('feathers-authentication:index');
const debug = Debug('@feathersjs/authentication:index');

module.exports = function init (config = {}) {
return function authentication () {
Expand Down
2 changes: 1 addition & 1 deletion lib/passport/authenticate.js
@@ -1,6 +1,6 @@
const makeDebug = require('debug');

const debug = makeDebug('feathers-authentication:passport:authenticate');
const debug = makeDebug('@feathersjs/authentication:passport:authenticate');

module.exports = function authenticate (options = {}) {
debug('Initializing custom passport authenticate', options);
Expand Down
2 changes: 1 addition & 1 deletion lib/passport/index.js
Expand Up @@ -2,7 +2,7 @@ const initialize = require('./initialize');
const authenticate = require('./authenticate');
const makeDebug = require('debug');

const debug = makeDebug('feathers-authentication:passport');
const debug = makeDebug('@feathersjs/authentication:passport');

module.exports = function feathersPassport (options) {
const app = this;
Expand Down
2 changes: 1 addition & 1 deletion lib/passport/initialize.js
Expand Up @@ -5,7 +5,7 @@ const {
verifyJWT
} = require('../utils');

const debug = makeDebug('feathers-authentication:passport:initialize');
const debug = makeDebug('@feathersjs/authentication:passport:initialize');

module.exports = function initialize (options = {}) {
// const app = this;
Expand Down
2 changes: 1 addition & 1 deletion lib/service.js
Expand Up @@ -2,7 +2,7 @@ const Debug = require('debug');
const merge = require('lodash.merge');
const express = require('./express');

const debug = Debug('feathers-authentication:authentication:service');
const debug = Debug('@feathersjs/authentication:authentication:service');

class Service {
constructor (app) {
Expand Down
2 changes: 1 addition & 1 deletion lib/socket/handler.js
Expand Up @@ -8,7 +8,7 @@ const {
const lt = require('long-timeout');
const updateEntity = require('./update-entity');

const debug = Debug('feathers-authentication:sockets:handler');
const debug = Debug('@feathersjs/authentication:sockets:handler');

function handleSocketCallback (promise, callback) {
if (typeof callback === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion lib/socket/index.js
@@ -1,7 +1,7 @@
const Debug = require('debug');
const setupSocketHandler = require('./handler');

const debug = Debug('feathers-authentication:sockets');
const debug = Debug('@feathersjs/authentication:sockets');

const socketio = function socketio (app, options = {}) {
debug('Setting up Socket.io authentication middleware with options:', options);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Expand Up @@ -5,7 +5,7 @@ const pick = require('lodash.pick');
const omit = require('lodash.omit');
const jwt = require('jsonwebtoken');

const debug = Debug('feathers-authentication:authentication:utils');
const debug = Debug('@feathersjs/authentication:authentication:utils');

exports.createJWT = function createJWT (payload = {}, options = {}) {
const VALID_KEYS = [
Expand Down