-
-
Notifications
You must be signed in to change notification settings - Fork 795
Expand file tree
/
Copy pathfixture.ts
More file actions
59 lines (50 loc) · 1.48 KB
/
fixture.ts
File metadata and controls
59 lines (50 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { feathers, Params } from '@feathersjs/feathers';
import express, { rest, errorHandler } from '@feathersjs/express';
import { memory } from '@feathersjs/adapter-memory';
import { AuthenticationService, JWTStrategy, AuthenticationRequest } from '@feathersjs/authentication';
import { express as oauth, OAuthStrategy } from '../src';
export class TestOAuthStrategy extends OAuthStrategy {
async authenticate (data: AuthenticationRequest, params: Params) {
const { fromMiddleware } = params;
const authResult = await super.authenticate(data, params);
if (fromMiddleware) {
authResult.fromMiddleware = fromMiddleware;
}
return authResult;
}
}
export const app = express(feathers());
const port = 9876;
const auth = new AuthenticationService(app);
auth.register('jwt', new JWTStrategy());
auth.register('test', new TestOAuthStrategy());
app.configure(rest());
app.set('host', '127.0.0.1');
app.set('port', port);
app.set('authentication', {
secret: 'supersecret',
entity: 'user',
service: 'users',
authStrategies: [ 'jwt' ],
oauth: {
defaults: {
transport: 'querystring'
},
test: {
key: 'some-key',
secret: 'a secret secret'
},
twitter: {
key: 'twitter key',
secret: 'some secret'
}
}
});
app.use((req, _res, next) => {
req.feathers = { fromMiddleware: 'testing' };
next();
});
app.use('/authentication', auth);
app.use('/users', memory());
app.configure(oauth());
app.use(errorHandler({ logger: null }));