Skip to content

Commit 44904e5

Browse files
committed
BC-27536:
Pass the RelayState from the request all the way to the response (required because we're going to use relaystate to correlate saml login requests to responses in hodor) Sign saml responses to better match what production IdP instances will be doing Add `gcompat` apk package in dockerfile to fix builds when running on ARM macs (see https://stackoverflow.com/questions/70963924/unable-to-load-nokogiri-in-docker-container-on-m1-mac) Signed-off-by: Hamish Farrant <[email protected]>
1 parent 731ec8a commit 44904e5

File tree

6 files changed

+13
-5
lines changed

6 files changed

+13
-5
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN chown -R app_user:app_user ${APP_DIR}
3232
USER app_user
3333

3434
FROM ruby:3.1.2-alpine
35-
RUN apk add --no-cache sqlite-dev
35+
RUN apk add --no-cache sqlite-dev gcompat
3636
RUN mkdir /app
3737
WORKDIR /app
3838
COPY --from=builder /app/public/ ./public

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ https://user-images.githubusercontent.com/783501/168935031-caab559e-7b5d-4056-96
2424
#### Docker
2525

2626
1. `docker build . -t saml-ruby-idp`
27-
2. `docker run --rm -p9292:9292 samp-ruby-idp`
27+
2. `docker run --rm -p9567:9292 saml-ruby-idp`
2828

2929
#### Ruby
3030

app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def user_ids
5656
post '/saml-login' do
5757
decode_request(params[:SAMLRequest])
5858

59-
@saml_response = encode_response(fake_user)
59+
@saml_response = encode_response(fake_user, signed_message: true)
6060

6161
haml :saml_post
6262
end

src/components/LoginForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
TextInput,
1111
Title,
1212
} from "@mantine/core";
13-
import { getSamlRequest } from "../utils";
13+
import { getSamlRequest, getRelayState } from "../utils";
1414
import { Ce, UserCircle } from "tabler-icons-react";
1515
interface LoginFormProps {
1616
username?: string;
@@ -31,6 +31,7 @@ const LoginForm: React.FunctionComponent<LoginFormProps> = ({ username }) => {
3131
onSubmit={() => submitting()}
3232
>
3333
<input type="hidden" name="SAMLRequest" value={getSamlRequest()} />
34+
<input type="hidden" name="RelayState" value={getRelayState()} />
3435
<Center>
3536
<Title order={1}>SAML Mock Identity Provider</Title>
3637
</Center>

src/utils.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ export const getSamlRequest = (): string => {
2121

2222
return urlParams.get('SAMLRequest') ?? ''
2323
}
24+
25+
export const getRelayState = (): string => {
26+
const queryString = window.location.search
27+
const urlParams = new URLSearchParams(queryString)
28+
29+
return urlParams.get('RelayState') ?? ''
30+
}

views/saml_post.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
%body{onload: "document.forms[0].submit();", style: "visibility:hidden;"}
88
%form{action: saml_acs_url, method: "post"}
99
%input{type: "hidden", name: "SAMLResponse", value: @saml_response}
10-
%input{type: "hidden", name: "RelayState", value: @relay_state}
10+
%input{type: "hidden", name: "RelayState", value: params[:RelayState]}
1111
%input{type: "submit", value: "Submit"}

0 commit comments

Comments
 (0)