Skip to content

Commit

Permalink
Merge pull request #133 from bugcrowd/BC-27536-pass-relay-state-throu…
Browse files Browse the repository at this point in the history
…gh-also-sign-requests-and-fix-builds-on-arm

BC-27536: Relay state, and assorted other fixes
  • Loading branch information
mo5h authored Oct 15, 2024
2 parents 731ec8a + 44904e5 commit 06894eb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN chown -R app_user:app_user ${APP_DIR}
USER app_user

FROM ruby:3.1.2-alpine
RUN apk add --no-cache sqlite-dev
RUN apk add --no-cache sqlite-dev gcompat
RUN mkdir /app
WORKDIR /app
COPY --from=builder /app/public/ ./public
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://user-images.githubusercontent.com/783501/168935031-caab559e-7b5d-4056-96
#### Docker

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

#### Ruby

Expand Down
2 changes: 1 addition & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def user_ids
post '/saml-login' do
decode_request(params[:SAMLRequest])

@saml_response = encode_response(fake_user)
@saml_response = encode_response(fake_user, signed_message: true)

haml :saml_post
end
Expand Down
3 changes: 2 additions & 1 deletion src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
TextInput,
Title,
} from "@mantine/core";
import { getSamlRequest } from "../utils";
import { getSamlRequest, getRelayState } from "../utils";
import { Ce, UserCircle } from "tabler-icons-react";
interface LoginFormProps {
username?: string;
Expand All @@ -31,6 +31,7 @@ const LoginForm: React.FunctionComponent<LoginFormProps> = ({ username }) => {
onSubmit={() => submitting()}
>
<input type="hidden" name="SAMLRequest" value={getSamlRequest()} />
<input type="hidden" name="RelayState" value={getRelayState()} />
<Center>
<Title order={1}>SAML Mock Identity Provider</Title>
</Center>
Expand Down
7 changes: 7 additions & 0 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ export const getSamlRequest = (): string => {

return urlParams.get('SAMLRequest') ?? ''
}

export const getRelayState = (): string => {
const queryString = window.location.search
const urlParams = new URLSearchParams(queryString)

return urlParams.get('RelayState') ?? ''
}
2 changes: 1 addition & 1 deletion views/saml_post.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
%body{onload: "document.forms[0].submit();", style: "visibility:hidden;"}
%form{action: saml_acs_url, method: "post"}
%input{type: "hidden", name: "SAMLResponse", value: @saml_response}
%input{type: "hidden", name: "RelayState", value: @relay_state}
%input{type: "hidden", name: "RelayState", value: params[:RelayState]}
%input{type: "submit", value: "Submit"}

0 comments on commit 06894eb

Please sign in to comment.