keycloak-mock
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,3 +6,3 @@ "use strict"; | ||
const { grant_type: grantType, client_id: clientID, scope } = body; | ||
if (instance.params.clientID !== clientID) { | ||
if (clientID && instance.params.clientID !== clientID) { | ||
return [400, "Bad request"]; | ||
@@ -19,7 +19,12 @@ } | ||
else if (grantType === "client_credentials") { | ||
const { client_secret: clientSecret } = body; | ||
if (!clientSecret) { | ||
const { username, password, client_secret: clientSecret } = body; | ||
if (!clientID && !username) { | ||
return [400, "Bad request"]; | ||
} | ||
user = instance.database.matchForClientGrant(clientID, clientSecret); | ||
if (!clientSecret && !password) { | ||
return [400, "Bad request"]; | ||
} | ||
// some clients specify the client ID and client secret as | ||
// username and password, hence the fallback | ||
user = instance.database.matchForClientGrant(clientID || username, clientSecret || password); | ||
} | ||
@@ -26,0 +31,0 @@ else { |
@@ -10,3 +10,3 @@ import { v4 as uuidv4 } from "uuid"; | ||
if (instance.params.clientID !== clientID) { | ||
if (clientID && instance.params.clientID !== clientID) { | ||
return [400, "Bad request"]; | ||
@@ -25,8 +25,18 @@ } | ||
} else if (grantType === "client_credentials") { | ||
const { client_secret: clientSecret } = body; | ||
if (!clientSecret) { | ||
const { username, password, client_secret: clientSecret } = body; | ||
if (!clientID && !username) { | ||
return [400, "Bad request"]; | ||
} | ||
user = instance.database.matchForClientGrant(clientID, clientSecret); | ||
if (!clientSecret && !password) { | ||
return [400, "Bad request"]; | ||
} | ||
// some clients specify the client ID and client secret as | ||
// username and password, hence the fallback | ||
user = instance.database.matchForClientGrant( | ||
clientID || username, | ||
clientSecret || password | ||
); | ||
} else { | ||
@@ -33,0 +43,0 @@ return [400, "Bad request"]; |
{ | ||
"name": "keycloak-mock", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Keycloak server mock for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
48625
1344