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

BC-27536: Relay state, and assorted other fixes #133

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
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"}
Loading