Skip to content

Commit

Permalink
[RND-663] Allow case insensitivity in OAuth requests (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
andonyns authored Dec 8, 2023
1 parent 57a4f6d commit 9cc502c
Show file tree
Hide file tree
Showing 21 changed files with 1,029 additions and 314 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-elasticsearch-backend",
"main": "dist/index.js",
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"description": "Meadowlark backend plugin for elasticsearch",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,8 +19,8 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-core": "0.4.0-pre.5",
"@edfi/meadowlark-utilities": "0.4.0-pre.5",
"@edfi/meadowlark-core": "0.4.0-pre.6",
"@edfi/meadowlark-utilities": "0.4.0-pre.6",
"@elastic/elasticsearch": "^8.10.0",
"@elastic/transport": "^8.3.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-mongodb-backend",
"main": "dist/index.js",
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"description": "Meadowlark backend plugin for MongoDB",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,9 +19,9 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-authz-server": "0.4.0-pre.5",
"@edfi/meadowlark-core": "0.4.0-pre.5",
"@edfi/meadowlark-utilities": "0.4.0-pre.5",
"@edfi/meadowlark-authz-server": "0.4.0-pre.6",
"@edfi/meadowlark-core": "0.4.0-pre.6",
"@edfi/meadowlark-utilities": "0.4.0-pre.6",
"async-retry": "^1.3.3",
"mongodb": "^5.9.0",
"ramda": "0.29.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-opensearch-backend",
"main": "dist/index.js",
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"description": "Meadowlark backend plugin for OpenSearch",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,8 +19,8 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-core": "0.4.0-pre.5",
"@edfi/meadowlark-utilities": "0.4.0-pre.5",
"@edfi/meadowlark-core": "0.4.0-pre.6",
"@edfi/meadowlark-utilities": "0.4.0-pre.6",
"@opensearch-project/opensearch": "^2.4.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-postgresql-backend",
"main": "dist/index.js",
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"description": "Meadowlark backend plugin for PostgreSQL",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -19,9 +19,9 @@
"build:copy-non-ts": "copyfiles -u 1 -e \"**/*.ts\" \"src/**/*\" dist --verbose"
},
"dependencies": {
"@edfi/meadowlark-authz-server": "0.4.0-pre.5",
"@edfi/meadowlark-core": "0.4.0-pre.5",
"@edfi/meadowlark-utilities": "0.4.0-pre.5",
"@edfi/meadowlark-authz-server": "0.4.0-pre.6",
"@edfi/meadowlark-core": "0.4.0-pre.6",
"@edfi/meadowlark-utilities": "0.4.0-pre.6",
"pg": "^8.11.3",
"pg-format": "^1.0.4",
"ramda": "0.29.1"
Expand Down
2 changes: 1 addition & 1 deletion Meadowlark-js/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"npmClient": "npm",
"useWorkspaces": true
}
66 changes: 34 additions & 32 deletions Meadowlark-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Meadowlark-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@shelf/jest-mongodb": "^4.1.7",
"@types/autocannon": "^7.12.1",
"@types/eslint": "^8.44.3",
"@types/jest": "^29.5.5",
"@types/jest": "^29.5.11",
"@types/node": "18.18.9",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
Expand Down
5 changes: 3 additions & 2 deletions Meadowlark-js/packages/meadowlark-authz-server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edfi/meadowlark-authz-server",
"main": "dist/index.js",
"version": "0.4.0-pre.5",
"version": "0.4.0-pre.6",
"description": "Meadowlark authorization server",
"license": "Apache-2.0",
"publishConfig": {
Expand All @@ -14,8 +14,9 @@
],
"dependencies": {
"@apideck/better-ajv-errors": "^0.3.6",
"@edfi/meadowlark-utilities": "0.4.0-pre.5",
"@edfi/meadowlark-utilities": "0.4.0-pre.6",
"ajv": "^8.12.0",
"didyoumean2": "^6.0.1",
"dotenv": "^16.3.1",
"fast-memoize": "^2.5.2",
"njwt": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AuthorizationRequest, extractAuthorizationHeader } from './Authorizatio
import { AuthorizationResponse } from './AuthorizationResponse';
import { CreateClientResponseBody } from '../model/CreateClientResponseBody';
import { writeDebugObject, writeDebugStatusToLog, writeErrorToLog, writeRequestToLog } from '../Logger';
import { BodyValidation, validateCreateClientBody } from '../validation/BodyValidation';
import { BodyValidation, applySuggestions, validateCreateClientBody } from '../validation/BodyValidation';
import { hashClientSecretBuffer } from '../security/HashClientSecret';
import { TryCreateBootstrapAuthorizationAdminResult } from '../message/TryCreateBootstrapAuthorizationAdminResult';
import { ClientId } from '../Utility';
Expand Down Expand Up @@ -119,7 +119,21 @@ export async function createClient(authorizationRequest: AuthorizationRequest):
return { body: { error }, statusCode: 400 };
}

const validation: BodyValidation = validateCreateClientBody(parsedBody);
let validation: BodyValidation = validateCreateClientBody(parsedBody);
// The validation will return suggestions for properties not found that have a similar match,
// here will apply it and validate once more, if this does not pass validation will return failure with the error message.
if (!validation.isValid && validation.suggestions) {
writeDebugStatusToLog(
moduleName,
authorizationRequest,
'createClient',
400,
'Invalid request body, checking for suggestions',
);
parsedBody = applySuggestions(parsedBody, validation.suggestions);
validation = validateCreateClientBody(parsedBody);
}

if (!validation.isValid) {
writeDebugObject(moduleName, authorizationRequest, 'createClient', 400, validation.failureMessage);
return {
Expand Down
Loading

0 comments on commit 9cc502c

Please sign in to comment.