Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: stop replacing spaces in SAML artifact #1325

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/app/modules/spcp/__tests__/spcp.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: true,
cookieDuration: MOCK_PARAMS.spCookieMaxAgePreserved,
samlArt: MOCK_SP_SAML,
})
})

Expand All @@ -293,7 +292,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: true,
cookieDuration: MOCK_PARAMS.cpCookieMaxAge,
samlArt: MOCK_CP_SAML,
})
})

Expand All @@ -311,7 +309,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: false,
cookieDuration: MOCK_PARAMS.spCookieMaxAge,
samlArt: MOCK_SP_SAML,
})
})

Expand All @@ -329,7 +326,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: false,
cookieDuration: MOCK_PARAMS.cpCookieMaxAge,
samlArt: MOCK_CP_SAML,
})
})

Expand All @@ -347,7 +343,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: false,
cookieDuration: MOCK_PARAMS.spCookieMaxAge,
samlArt: MOCK_SP_SAML,
})
})

Expand All @@ -365,7 +360,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}`,
rememberMe: false,
cookieDuration: MOCK_PARAMS.cpCookieMaxAge,
samlArt: MOCK_CP_SAML,
})
})

Expand All @@ -383,7 +377,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}/`,
rememberMe: true,
cookieDuration: MOCK_PARAMS.spCookieMaxAgePreserved,
samlArt: MOCK_SP_SAML,
})
})

Expand All @@ -401,7 +394,6 @@ describe('spcp.service', () => {
destination: `/${MOCK_TARGET}/`,
rememberMe: true,
cookieDuration: MOCK_PARAMS.cpCookieMaxAge,
samlArt: MOCK_CP_SAML,
})
})

Expand Down
22 changes: 6 additions & 16 deletions src/app/modules/spcp/spcp.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,13 @@ export const handleLogin: (
unknown,
{ SAMLart: string; RelayState: string }
> = (authType) => async (req, res) => {
const { SAMLart: rawSamlArt, RelayState: rawRelayState } = req.query
const { SAMLart, RelayState } = req.query
const logMeta = {
action: 'handleLogin',
samlArt: rawSamlArt,
relayState: rawRelayState,
samlArt: SAMLart,
relayState: RelayState,
}
const parseResult = SpcpFactory.parseOOBParams(
rawSamlArt,
rawRelayState,
authType,
)
const parseResult = SpcpFactory.parseOOBParams(SAMLart, RelayState, authType)
if (parseResult.isErr()) {
logger.error({
message: 'Invalid SPCP login parameters',
Expand All @@ -202,13 +198,7 @@ export const handleLogin: (
})
return res.sendStatus(StatusCodes.BAD_REQUEST)
}
const {
formId,
destination,
rememberMe,
cookieDuration,
samlArt,
} = parseResult.value
const { formId, destination, rememberMe, cookieDuration } = parseResult.value
const formResult = await FormService.retrieveFullFormById(formId)
if (formResult.isErr()) {
logger.error({
Expand All @@ -232,7 +222,7 @@ export const handleLogin: (
return res.redirect(destination)
}
const jwtResult = await SpcpFactory.getSpcpAttributes(
samlArt,
SAMLart,
destination,
authType,
)
Expand Down
2 changes: 0 additions & 2 deletions src/app/modules/spcp/spcp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ export class SpcpService {
destination,
rememberMe,
cookieDuration,
// Resolve known express req.query issue where pluses become spaces
samlArt: String(samlArt).replace(/ /g, '+'),
})
} else {
logger.error({
Expand Down
1 change: 0 additions & 1 deletion src/app/modules/spcp/spcp.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ export interface ParsedSpcpParams {
destination: string
rememberMe: boolean
cookieDuration: number
samlArt: string
}