Skip to content

Commit bd1d21f

Browse files
rashisfRashi1398
andauthored
updated (#17)
Co-authored-by: Rashi <[email protected]>
1 parent d866b66 commit bd1d21f

File tree

37 files changed

+6102
-1568
lines changed

37 files changed

+6102
-1568
lines changed

ELIFECYCLE

Whitespace-only changes.

package-lock.json

Lines changed: 5662 additions & 1433 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,43 @@
4545
"!*/__tests__"
4646
],
4747
"peerDependencies": {
48-
"@loopback/boot": "^1.4.4",
49-
"@loopback/context": "^1.20.2",
50-
"@loopback/core": "^1.8.5",
51-
"@loopback/rest": "^1.16.3"
48+
"@loopback/boot": "^2.1.2",
49+
"@loopback/context": "^3.6.0",
50+
"@loopback/core": "^2.4.2",
51+
"@loopback/rest": "^3.3.2"
5252
},
5353
"dependencies": {
54-
"passport": "^0.4.0",
54+
"passport": "^0.4.1",
5555
"passport-google-oauth20": "^2.0.0",
5656
"passport-http-bearer": "^1.0.1",
5757
"passport-local": "^1.0.0",
58-
"passport-oauth2-client-password": "^0.1.2"
58+
"passport-oauth2-client-password": "^0.1.2",
59+
"passport-azure-ad": "^4.2.1"
5960
},
6061
"devDependencies": {
61-
"@istanbuljs/nyc-config-typescript": "^0.1.3",
62-
"@loopback/boot": "^1.4.4",
63-
"@loopback/build": "^2.0.5",
64-
"@loopback/context": "^1.20.2",
65-
"@loopback/core": "^1.8.5",
66-
"@loopback/rest": "^1.16.3",
67-
"@loopback/testlab": "^1.6.3",
62+
"@istanbuljs/nyc-config-typescript": "^1.0.1",
63+
"@loopback/boot": "^2.1.2",
64+
"@loopback/build": "^5.3.0",
65+
"@loopback/context": "^3.6.0",
66+
"@loopback/core": "^2.4.2",
67+
"@loopback/metadata": "^2.1.2",
68+
"@loopback/rest": "^3.3.2",
69+
"@loopback/testlab": "^3.1.2",
6870
"@loopback/tslint-config": "^2.1.0",
69-
"@types/express": "^4.17.0",
70-
"@types/lodash": "^4.14.135",
71-
"@types/node": "^10.14.8",
72-
"@types/passport": "^1.0.0",
73-
"@types/passport-google-oauth20": "^2.0.1",
74-
"@types/passport-http-bearer": "^1.0.33",
71+
"@types/express": "^4.17.6",
72+
"@types/lodash": "^4.14.150",
73+
"@types/node": "^13.13.4",
74+
"@types/passport": "^1.0.3",
75+
"@types/passport-azure-ad": "^4.0.5",
76+
"@types/passport-google-oauth20": "^2.0.3",
77+
"@types/passport-http-bearer": "^1.0.35",
7578
"@types/passport-local": "^1.0.33",
7679
"@types/passport-oauth2-client-password": "^0.1.2",
77-
"lodash": "^4.17.14",
78-
"nyc": "^14.1.1",
79-
"source-map-support": "^0.5.12",
80-
"ts-node": "^8.3.0",
81-
"tslint": "^5.18.0",
82-
"typescript": "^3.5.2"
80+
"lodash": "^4.17.15",
81+
"nyc": "^15.0.1",
82+
"source-map-support": "^0.5.19",
83+
"ts-node": "^8.10.1",
84+
"tslint": "^6.1.2",
85+
"typescript": "^3.8.3"
8386
}
8487
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Provider} from '@loopback/core';
2+
import {VerifyFunction} from '../../../strategies';
3+
import * as AzureADAuthStrategy from 'passport-azure-ad';
4+
import {IAuthUser} from '../../../types';
5+
import {Request} from '@loopback/rest';
6+
7+
export class BearerTokenVerifyProvider
8+
implements Provider<VerifyFunction.AzureADAuthFn> {
9+
constructor() {}
10+
11+
value() {
12+
return async (
13+
profile: AzureADAuthStrategy.IProfile,
14+
done: AzureADAuthStrategy.VerifyCallback,
15+
req?: Request,
16+
) => {
17+
const userToPass: IAuthUser = {
18+
id: 1,
19+
username: 'xyz',
20+
password: 'pass',
21+
};
22+
23+
return userToPass;
24+
};
25+
}
26+
}

src/__tests__/fixtures/providers/google-auth.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Provider} from '@loopback/core';
22
import {VerifyFunction} from '../../../strategies';
33
import * as GoogleStrategy from 'passport-google-oauth20';
44
import {IAuthUser} from '../../../types';
5+
import {Request} from '@loopback/rest';
56

67
export class BearerTokenVerifyProvider
78
implements Provider<VerifyFunction.GoogleAuthFn> {
@@ -12,6 +13,8 @@ export class BearerTokenVerifyProvider
1213
accessToken: string,
1314
refreshToken: string,
1415
profile: GoogleStrategy.Profile,
16+
cb: GoogleStrategy.VerifyCallback,
17+
req?: Request,
1518
) => {
1619
const userToPass: IAuthUser = {
1720
id: 1,

src/__tests__/integration/passport-bearer/bearer-token-verify.integration.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ describe('Bearer-token strategy', () => {
3232

3333
app.controller(BearerNoTokenController);
3434

35-
await whenIMakeRequestTo(server)
36-
.get('/auth/bearer/no-token')
37-
.expect(401);
35+
await whenIMakeRequestTo(server).get('/auth/bearer/no-token').expect(401);
3836
});
3937

4038
it('should return status 200 when token is passed', async () => {

src/__tests__/integration/passport-client-password/client-password-verify.integration.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ describe('Client-password strategy', () => {
8181

8282
@post('/test')
8383
@authenticateClient(STRATEGY.CLIENT_PASSWORD, {passReqToCallback: true})
84-
async test(@requestBody()
85-
body: {
86-
client_id: string;
87-
client_secret: string;
88-
}) {
84+
async test(
85+
@requestBody()
86+
body: {
87+
client_id: string;
88+
client_secret: string;
89+
},
90+
) {
8991
return this.client;
9092
}
9193
}
@@ -107,11 +109,13 @@ describe('Client-password strategy', () => {
107109

108110
@post('/test')
109111
@authenticateClient(STRATEGY.CLIENT_PASSWORD, {passReqToCallback: false})
110-
async test(@requestBody()
111-
body: {
112-
client_id: string;
113-
client_secret: string;
114-
}) {
112+
async test(
113+
@requestBody()
114+
body: {
115+
client_id: string;
116+
client_secret: string;
117+
},
118+
) {
115119
return this.client;
116120
}
117121
}
@@ -160,11 +164,13 @@ describe('integration test for client-password and no verifier', () => {
160164

161165
@post('/test')
162166
@authenticateClient(STRATEGY.CLIENT_PASSWORD, {passReqToCallback: true})
163-
test(@requestBody()
164-
body: {
165-
client_id: string;
166-
client_secret: string;
167-
}) {
167+
test(
168+
@requestBody()
169+
body: {
170+
client_id: string;
171+
client_secret: string;
172+
},
173+
) {
168174
return this.client;
169175
}
170176
}

src/__tests__/integration/passport-google-oauth2/google-oauth2.integration.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ describe('getting google oauth2 strategy with options', () => {
3434

3535
app.controller(TestController);
3636

37-
await whenIMakeRequestTo(server)
38-
.get('/test')
39-
.expect(200);
37+
await whenIMakeRequestTo(server).get('/test').expect(200);
4038
});
4139

4240
function whenIMakeRequestTo(restServer: RestServer): Client {
@@ -69,6 +67,7 @@ class GoogleAuthVerifyProvider
6967
accessToken: string,
7068
refreshToken: string,
7169
profile: GoogleStrategy.Profile,
70+
cd: GoogleStrategy.VerifyCallback,
7271
req?: Request,
7372
) => {
7473
return userWithoutReqObj;

src/__tests__/integration/passport-resource-owner-password/resource-owner-password.integration.ts

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ describe('Resource-owner-password strategy', () => {
4444

4545
@post('/auth/resource-owner-pass/no-options')
4646
@authenticate(STRATEGY.OAUTH2_RESOURCE_OWNER_GRANT)
47-
test(@requestBody()
48-
body: {
49-
username: string;
50-
password: string;
51-
client_id: string;
52-
client_secret: string;
53-
}) {
47+
test(
48+
@requestBody()
49+
body: {
50+
username: string;
51+
password: string;
52+
client_id: string;
53+
client_secret: string;
54+
},
55+
) {
5456
return this.user;
5557
}
5658
}
@@ -84,13 +86,15 @@ describe('Resource-owner-password strategy', () => {
8486
@authenticate(STRATEGY.OAUTH2_RESOURCE_OWNER_GRANT, {
8587
passReqToCallback: true,
8688
})
87-
async test(@requestBody()
88-
body: {
89-
username: string;
90-
password: string;
91-
client_id: string;
92-
client_secret: string;
93-
}) {
89+
async test(
90+
@requestBody()
91+
body: {
92+
username: string;
93+
password: string;
94+
client_id: string;
95+
client_secret: string;
96+
},
97+
) {
9498
return this.user;
9599
}
96100
}
@@ -124,13 +128,15 @@ describe('Resource-owner-password strategy', () => {
124128
@authenticate(STRATEGY.OAUTH2_RESOURCE_OWNER_GRANT, {
125129
passReqToCallback: false,
126130
})
127-
async test(@requestBody()
128-
body: {
129-
username: string;
130-
password: string;
131-
client_id: string;
132-
client_secret: string;
133-
}) {
131+
async test(
132+
@requestBody()
133+
body: {
134+
username: string;
135+
password: string;
136+
client_id: string;
137+
client_secret: string;
138+
},
139+
) {
134140
return this.user;
135141
}
136142
}
@@ -157,13 +163,15 @@ describe('Resource-owner-password strategy', () => {
157163
class TestController {
158164
@post('/test')
159165
@authenticate(STRATEGY.OAUTH2_RESOURCE_OWNER_GRANT)
160-
async test(@requestBody()
161-
body: {
162-
username: string;
163-
password: string;
164-
client_id: string;
165-
client_secret: string;
166-
}) {
166+
async test(
167+
@requestBody()
168+
body: {
169+
username: string;
170+
password: string;
171+
client_id: string;
172+
client_secret: string;
173+
},
174+
) {
167175
return body;
168176
}
169177
}
@@ -216,13 +224,15 @@ describe('Resource-owner strategy with no verifier', () => {
216224

217225
@post('/test')
218226
@authenticate(STRATEGY.OAUTH2_RESOURCE_OWNER_GRANT)
219-
async test(@requestBody()
220-
body: {
221-
username: string;
222-
password: string;
223-
client_id: string;
224-
client_secret: string;
225-
}) {
227+
async test(
228+
@requestBody()
229+
body: {
230+
username: string;
231+
password: string;
232+
client_id: string;
233+
client_secret: string;
234+
},
235+
) {
226236
return body;
227237
}
228238
}

0 commit comments

Comments
 (0)