Skip to content

Commit

Permalink
feat!: MFA in example project, massive improvements and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Nov 21, 2023
1 parent b3caf4a commit 074a9cb
Show file tree
Hide file tree
Showing 271 changed files with 23,466 additions and 5,974 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/docker-publish-iam-nginx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Docker-publish-iam-nginx

on:
release:
types:
- published
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
REPO_NAME: ${{ github.repository }}
IMAGE_NAME: xdrplus-iam-nginx
FULL_IMAGE_NAME: 4securitas/xdrplus-iam-nginx
VENDOR_NAME: xdrplus
CONTEXT: .
DOCKERFILE: compose/nginx/Dockerfile


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.1.1'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.FULL_IMAGE_NAME }}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=${{ env.IMAGE_NAME }}
org.opencontainers.image.vendor=${{ env.VENDOR_NAME }}
org.opencontainers.image.url=https://github.com/${{ env.FULL_IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: ${{ env.CONTEXT }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: ${{ env.DOCKERFILE }}


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
94 changes: 94 additions & 0 deletions .github/workflows/docker-publish-iam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Docker-publish-iam

on:
release:
types:
- published
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
REPO_NAME: ${{ github.repository }}
IMAGE_NAME: xdrplus-iam
FULL_IMAGE_NAME: 4securitas/xdrplus-iam
VENDOR_NAME: xdrplus
CONTEXT: .

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.1.1'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.FULL_IMAGE_NAME }}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=${{ env.IMAGE_NAME }}
org.opencontainers.image.vendor=${{ env.VENDOR_NAME }}
org.opencontainers.image.url=https://github.com/${{ env.FULL_IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: ${{ env.CONTEXT }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
40 changes: 29 additions & 11 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,33 @@ on:
branches: [ master, dev ]

jobs:
build:

pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
skip_after_successful_duplicate: 'true'
same_content_newer: 'true'

main_job:

needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.11'
- '3.10'
django-version:
- '3.1'
- '4.2'
- '3.2'

steps:
Expand All @@ -41,17 +55,21 @@ jobs:
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-customizations.txt ]; then pip install -r requirements-customizations.txt; fi
- name: List installed python dependencies
run: |
python -m pip list
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 uniauth_saml2_idp --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 uniauth_saml2_idp --count --exit-zero --statistics --max-line-length 160 --exclude=*migrations*
- name: Bandit Security Scan
run: |
bandit -r -x uniauth_saml2_idp/test* uniauth_saml2_idp/*
- name: Test with Django tests
working-directory: ./example
working-directory: ./xdrplus-iam
run: |
# pytest --cov-config=.coveragerc --cov=../ -v --ignore=tests/test_05_ldap_datastore.py
pytest --cov-config=.coveragerc -v --cov=../
#- name: Bandit Security Scan
#run: |
#bandit -r -x test* uniauth/*
coverage erase
coverage run manage.py test
coverage report -m --skip-covered
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ static/*
certificates/*
!certificates/README.md
data/metadata/*
!data/metadata/satosa.xml
django_idp/idp_pysaml2.py
documentation/_build/
tests/data/metadata/*
tests/sp/metadata/*
uniauth_saml2_idp/tests/data/metadata/*
uniauth_saml2_idp/tests/sp/metadata/*
.coverage
.pytest_cache
*.sqlite3
pcvalidate

example-docker
example_sp/djangosaml2_sp/sqlite3.db
xdrplus-iam/logs/*.log
xdrplus-iam/logs/*.log.*

xdrplus-iam/data/media/*
!xdrplus-iam/data/media/README.md
Loading

0 comments on commit 074a9cb

Please sign in to comment.