Skip to content

Commit

Permalink
feat: 3.1.0 roles in security schema for all types (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomFrost authored Jan 7, 2021
1 parent 590649a commit 6d2a14d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
13 changes: 0 additions & 13 deletions src/middlewares/openapi.security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ class AuthValidator {
if (type === 'basic' && !authHeader.includes('basic')) {
throw Error(`Authorization header with scheme 'Basic' required`);
}

this.dissallowScopes();
}
}

Expand All @@ -300,17 +298,6 @@ class AuthValidator {
throw Error(`cookie '${scheme.name}' required`);
}
}

this.dissallowScopes();
}
}

private dissallowScopes(): void {
if (this.scopes.length > 0) {
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#security-requirement-object
throw new InternalServerError({
message: "scopes array must be empty for security type 'http'",
});
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions test/security.handlers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,6 @@ describe('security.handlers', () => {
});
});

it('should return 500 if scopes are no allowed', async () =>
request(app)
.get(`${basePath}/api_key_with_scopes`)
.set('X-Api-Key', 'XXX')
.expect(500)
.then((r) => {
const body = r.body;
expect(body.message).to.equal(
"scopes array must be empty for security type 'http'",
);
}));

it('should return 200 if api_key or anonymous and no api key is supplied', async () => {
const validateSecurity = <ValidateSecurityOpts>eovConf.validateSecurity;
validateSecurity.handlers.ApiKeyAuth = <any>((req, scopes, schema) => true);
Expand Down

0 comments on commit 6d2a14d

Please sign in to comment.