Skip to content

Commit 6d2a14d

Browse files
authored
feat: 3.1.0 roles in security schema for all types (#513)
1 parent 590649a commit 6d2a14d

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

src/middlewares/openapi.security.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ class AuthValidator {
279279
if (type === 'basic' && !authHeader.includes('basic')) {
280280
throw Error(`Authorization header with scheme 'Basic' required`);
281281
}
282-
283-
this.dissallowScopes();
284282
}
285283
}
286284

@@ -300,17 +298,6 @@ class AuthValidator {
300298
throw Error(`cookie '${scheme.name}' required`);
301299
}
302300
}
303-
304-
this.dissallowScopes();
305-
}
306-
}
307-
308-
private dissallowScopes(): void {
309-
if (this.scopes.length > 0) {
310-
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#security-requirement-object
311-
throw new InternalServerError({
312-
message: "scopes array must be empty for security type 'http'",
313-
});
314301
}
315302
}
316303
}

test/security.handlers.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,6 @@ describe('security.handlers', () => {
351351
});
352352
});
353353

354-
it('should return 500 if scopes are no allowed', async () =>
355-
request(app)
356-
.get(`${basePath}/api_key_with_scopes`)
357-
.set('X-Api-Key', 'XXX')
358-
.expect(500)
359-
.then((r) => {
360-
const body = r.body;
361-
expect(body.message).to.equal(
362-
"scopes array must be empty for security type 'http'",
363-
);
364-
}));
365-
366354
it('should return 200 if api_key or anonymous and no api key is supplied', async () => {
367355
const validateSecurity = <ValidateSecurityOpts>eovConf.validateSecurity;
368356
validateSecurity.handlers.ApiKeyAuth = <any>((req, scopes, schema) => true);

0 commit comments

Comments
 (0)