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

feat: add samlify example #130

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ec66b30
added remix saml auth example
christopherpickering Jan 16, 2023
14bfa7a
simplified example
christopherpickering Jan 20, 2023
759c30a
removed migrations folder so initial setup will work
christopherpickering Jan 20, 2023
2a179ea
renamed
christopherpickering Jan 20, 2023
a2e3d29
fixed submodule
christopherpickering Jan 20, 2023
6c04bb1
removed old files
christopherpickering Jan 20, 2023
9958b81
passed lint, removed git submodule
christopherpickering Jan 23, 2023
58d3757
removed unused line
christopherpickering Jan 23, 2023
6f34075
Update auth-saml-ldap/app/root.tsx
christopherpickering Jan 23, 2023
bba6ac2
Update auth-saml-ldap/app/routes/logout.tsx
christopherpickering Jan 23, 2023
cc69f3c
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
c85a62a
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
91e297c
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
e2736e4
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
bdcf116
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
0e9eb14
Update auth-saml-ldap/app/routes/index.tsx
christopherpickering Jan 23, 2023
53fd18f
Update auth-saml-ldap/app/ldap.server.tsx
christopherpickering Jan 23, 2023
a8e8612
Update auth-saml-ldap/app/routes/index.tsx
christopherpickering Jan 23, 2023
0eff246
Update auth-saml-ldap/app/routes/login.tsx
christopherpickering Jan 23, 2023
7d49ff8
Update auth-saml-ldap/app/routes/auth/asc.tsx
christopherpickering Jan 23, 2023
221f387
Update auth-saml-ldap/app/routes/auth/asc.tsx
christopherpickering Jan 23, 2023
843192b
Update auth-saml-ldap/app/models/user.server.ts
christopherpickering Jan 23, 2023
af4e4e4
Update auth-saml-ldap/app/models/user.server.ts
christopherpickering Jan 23, 2023
17d444e
Update auth-saml-ldap/app/models/user.server.ts
christopherpickering Jan 23, 2023
1a4efbe
Update auth-saml-ldap/app/models/user.server.ts
christopherpickering Jan 23, 2023
84f4563
Update auth-saml-ldap/app/routes/auth/asc.tsx
christopherpickering Jan 23, 2023
bdcbc69
Update auth-saml-ldap/app/routes/auth/asc.tsx
christopherpickering Jan 23, 2023
d961132
Update auth-saml-ldap/app/routes/auth/asc.tsx
christopherpickering Jan 23, 2023
35ba527
updated recommendations and lint
christopherpickering Jan 24, 2023
9c7e172
removed uneeded await
christopherpickering Jan 25, 2023
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
7 changes: 7 additions & 0 deletions remix-auth-saml/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/node_modules
*.log
.DS_Store
.env
/.cache
/public/build
/build
20 changes: 20 additions & 0 deletions remix-auth-saml/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
SESSION_SECRET="super-duper-s3cret"

SESSION_SECRET="03e0f8241c4fc7bb9b97528f59dfb5ce"

SAML_IDP_METADATA="http://localhost:7000/metadata"

SAML_SP_AUTHNREQUESTSSIGNED=false
SAML_SP_WANTMESSAGESIGNED=false
SAML_SP_WANTASSERTIONSIGNED=false
SAML_SP_WANTLOGOUTREQUESTSIGNED=false

SAML_PRIVATE_KEY="/path/to/saml-idp/idp-private-key.pem"
SAML_PRIVATE_KEY_PASS=""

SAML_ENC_PRIVATE_KEY="/path/to/saml-idp/idp-private-key.pem"

SAML_SP_ISASSERTIONENCRYPTED=false

HOSTNAME="http://localhost:3000"
21 changes: 21 additions & 0 deletions remix-auth-saml/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @type {import('@types/eslint').Linter.BaseConfig} */
module.exports = {
extends: [
"@remix-run/eslint-config",
"@remix-run/eslint-config/node",
"@remix-run/eslint-config/jest-testing-library",
"prettier",
],
env: {
"cypress/globals": true,
},
plugins: ["cypress"],
// We're using vitest which has a very similar API to jest
// (so the linting plugins work nicely), but we have to
// set the jest version explicitly.
settings: {
jest: {
version: 28,
},
},
};
220 changes: 220 additions & 0 deletions remix-auth-saml/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
name: 🚀 Deploy
on:
push:
branches:
- main
- dev
pull_request: {}

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🔬 Lint
run: npm run lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🔎 Type check
run: npm run typecheck --if-present

vitest:
name: ⚡ Vitest
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: ⚡ Run vitest
run: npm run test -- --coverage

cypress:
name: ⚫️ Cypress
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🏄 Copy test env vars
run: cp .env.example .env

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🐳 Docker compose
# the sleep is just there to give time for postgres to get started
run: docker-compose up -d && sleep 3
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"

- name: 🛠 Setup Database
run: npx prisma migrate reset --force

- name: ⚙️ Build
run: npm run build

- name: 🌳 Cypress run
uses: cypress-io/github-action@v5
with:
start: npm run start:mocks
wait-on: "http://localhost:8811"
env:
PORT: "8811"

build:
name: 🐳 Build
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: "fly.toml"
field: "app"

- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Setup cache
- name: ⚡️ Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: 🔑 Fly Registry Auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: 🐳 Docker build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, vitest, cypress, build]
# only build/deploy main branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}

steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: "fly.toml"
field: "app"

- name: 🚀 Deploy Staging
if: ${{ github.ref == 'refs/heads/dev' }}
uses: superfly/[email protected]
with:
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/[email protected]
with:
args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
12 changes: 12 additions & 0 deletions remix-auth-saml/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
node_modules

/build
/public/build
.env

/cypress/screenshots
/cypress/videos
/postgres-data

/app/styles/tailwind.css
9 changes: 9 additions & 0 deletions remix-auth-saml/.gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM gitpod/workspace-full

# Install Fly
RUN curl -L https://fly.io/install.sh | sh
ENV FLYCTL_INSTALL="/home/gitpod/.fly"
ENV PATH="$FLYCTL_INSTALL/bin:$PATH"

# Install GitHub CLI
RUN brew install gh
56 changes: 56 additions & 0 deletions remix-auth-saml/.gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# https://www.gitpod.io/docs/config-gitpod-file

image:
file: .gitpod.Dockerfile

ports:
- port: 3000
onOpen: notify

tasks:
- name: Restore .env file
command: |
if [ -f .env ]; then
# If this workspace already has a .env, don't override it
# Local changes survive a workspace being opened and closed
# but they will not persist between separate workspaces for the same repo

echo "Found .env in workspace"
else
# There is no .env
if [ ! -n "${ENV}" ]; then
# There is no $ENV from a previous workspace
# Default to the example .env
echo "Setting example .env"

cp .env.example .env
else
# After making changes to .env, run this line to persist it to $ENV
# eval $(gp env -e ENV="$(base64 .env | tr -d '\n')")
#
# Environment variables set this way are shared between all your workspaces for this repo
# The lines below will read $ENV and print a .env file

echo "Restoring .env from Gitpod"

echo "${ENV}" | base64 -d | tee .env > /dev/null
fi
fi

- name: Docker
init: docker-compose pull
command: docker-compose up

- init: npm install
command: |
gp await-port 5432
npm run setup
npm run build
npm run dev

vscode:
extensions:
- ms-azuretools.vscode-docker
- esbenp.prettier-vscode
- dbaeumer.vscode-eslint
- bradlc.vscode-tailwindcss
1 change: 1 addition & 0 deletions remix-auth-saml/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
11 changes: 11 additions & 0 deletions remix-auth-saml/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules

/build
/public/build
.env

/cypress/screenshots
/cypress/videos
/postgres-data

/app/styles/tailwind.css
Loading