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

Enable OAuth2 authentication #602

Closed
wants to merge 107 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
a107b3a
Enable OAuth2 authentication.
Jun 25, 2024
fe6c816
Enable OAuth2 authentication.
Jun 25, 2024
f66fca3
Merge remote-tracking branch 'origin/oauth2' into oauth2
Jun 25, 2024
cfb206c
Removing secrets from policy_store/config route and deprecating this …
obsd Jun 25, 2024
fe3ed70
make exclude API params configureable to not break OSS
obsd Jun 25, 2024
e49bc26
fix lint
obsd Jun 26, 2024
00aea98
Merge pull request #603 from permitio/oded/per-10149-remove-old-route…
obsd Jun 26, 2024
bca6cb5
Fix env var description
obsd Jun 26, 2024
0d34580
dan/per-10181-release-a-new-opal-client-cedar-version (#605)
danyi1212 Jun 26, 2024
5857f64
Update tests.yml
danyi1212 Jun 27, 2024
3fba32e
BasePolicyWatcherTask: Signal stop if broadcaster fails to connect
roekatz Jun 26, 2024
73ea4d5
Random documentation fixes
roekatz Jun 26, 2024
36e6dc1
Fix tests to explicitly choose 'master' as default branch
roekatz Jun 27, 2024
03c011f
Tests: Change test server ports to avoid collisions
roekatz Jun 27, 2024
6d80630
Dokcer test: No need to build test image for client cedar since we do…
roekatz Jun 27, 2024
384df7e
Merge pull request #604 from permitio/oded/per-10149-remove-old-route…
obsd Jun 30, 2024
6fff757
Merge pull request #606 from permitio/rk/raise-broadcaster-conn-failu…
roekatz Jul 2, 2024
c3cf66b
Revert "BasePolicyWatcherTask: Signal stop if broadcaster fails to co…
roekatz Jul 3, 2024
94f9874
dan/per-10201-fix-opal-server-077-failures (#607)
danyi1212 Jul 7, 2024
93161a0
fix: requirements.txt to reduce vulnerabilities
snyk-bot Jul 10, 2024
b3d4625
Merge pull request #610 from permitio/rk/revert-broadcast-conn-failur…
roekatz Jul 10, 2024
9f3efba
Bump version to 0.7.8
roekatz Jul 13, 2024
b8c8306
Merge pull request #615 from permitio/rk/bump-ver-0.7.8
roekatz Jul 13, 2024
5f0a821
CI: Remove unnecessary (and buggy) build of cedar & standalone client…
roekatz Jul 13, 2024
362380b
Merge pull request #616 from permitio/rk/fix-release-flow
roekatz Jul 13, 2024
0f79bcd
CI: Comment out failing opal cedar client build
roekatz Jul 13, 2024
ff0f350
Merge pull request #617 from permitio/rk/fix-release-flow
roekatz Jul 13, 2024
8b691d9
Changed relative imports to absolute
danyi1212 Jul 14, 2024
38446a8
Renamed redis_utils module
danyi1212 Jul 14, 2024
040162c
Renamed http_utils module
danyi1212 Jul 14, 2024
8dd6cc1
Renamed logging_utils module
danyi1212 Jul 14, 2024
c1c6d0f
Renamed git_utils module
danyi1212 Jul 14, 2024
8d09526
fix: packages/requires.txt to reduce vulnerabilities
snyk-bot Jul 16, 2024
3801481
Fixed statistics API (#622)
danyi1212 Jul 16, 2024
e5f5dba
dan/per-10200-write-docs-on-how-to-use-opal (#612)
danyi1212 Jul 16, 2024
1f6ce77
Bump version to 0.7.9
roekatz Jul 17, 2024
ec8478d
Merge pull request #624 from permitio/rk/bump-0.7.9
roekatz Jul 17, 2024
208253b
Fix opal-server addr to opal-server rather than host.docker.internal
roekatz Jul 10, 2024
ba89632
CI test-docker: Also make sure opal-client fetched data sources
roekatz Jul 18, 2024
8c30c89
Docker-compose: Remove obsolete `version` field
roekatz Jul 18, 2024
51574f5
Merge pull request #627 from permitio/roe/per-10336-opal-cis-docker-t…
roekatz Jul 18, 2024
5f01375
Fixed OPAL Cedar Client build CI
danyi1212 Jul 22, 2024
6ae6b18
Updated rust version for OPAL Cedar Client docker
danyi1212 Jul 22, 2024
63c27c8
Fixed docker warnings
danyi1212 Jul 22, 2024
ed70c74
Fixed cedar build
danyi1212 Jul 22, 2024
8bc8924
Merge pull request #628 from permitio/dan/per-10181-fix-opal-cedar-cl…
danyi1212 Jul 23, 2024
0c00444
Merge branch 'refs/heads/master' into dan/per-10298-fix-relative-impo…
danyi1212 Jul 23, 2024
0310701
Fixed pre-commit
danyi1212 Jul 23, 2024
d42310b
Merge pull request #618 from permitio/dan/per-10298-fix-relative-impo…
danyi1212 Jul 23, 2024
3eee3e7
Bump version to 0.7.10
roekatz Jul 24, 2024
6395f05
Merge pull request #631 from permitio/roe/bump-0.7.10
roekatz Jul 24, 2024
82b4149
Hardcode peer_type = datasource
Jul 26, 2024
e53f4a6
Rebase feature branch onto updated master
Jul 26, 2024
d45ba12
Enable OAuth2 authentication.
Jun 25, 2024
917ea66
Hardcode peer_type = datasource
Jul 26, 2024
5cd04e3
Merge remote-tracking branch 'origin/oauth2' into oauth2
Jul 26, 2024
bd0777c
Add sync workflow for OPAL+ repository (#630)
danyi1212 Jul 28, 2024
84beb45
added pypi release (#629)
EliMoshkovich Aug 1, 2024
41ea4e4
Add Docker Compose examples with OAuth2 token validations
Aug 1, 2024
29139c4
Remove hardcoded peer_type claim
Aug 1, 2024
22f0ee0
Rebase feature branch onto updated master
Jul 26, 2024
2d958c9
Enable OAuth2 authentication.
Jun 25, 2024
db9dae0
Hardcode peer_type = datasource
Jul 26, 2024
630d28c
Rebase to master
Aug 6, 2024
707c766
Enable OAuth2 authentication.
Jun 25, 2024
b5c8451
Add Docker Compose examples with OAuth2 token validations
Aug 1, 2024
28be097
Remove unused imports
Aug 6, 2024
7a29e9a
Merge remote-tracking branch 'origin/oauth2' into oauth2
Aug 6, 2024
fb0419e
docker-compose install and delete duplicate github token
EliMoshkovich Aug 6, 2024
f1a4e84
Fix pre-commit trailing whitespace
roekatz Aug 7, 2024
7291053
Merge pull request #636 from permitio/PER-9644-cicd-fix
roekatz Aug 7, 2024
0d727c3
update docs packages to fix snyk alerts
obsd Aug 6, 2024
4d62d9c
Merge pull request #621 from permitio/snyk-fix-02175ecd477a17e3ae0a5d…
roekatz Aug 7, 2024
d7b047d
typo fixed in set_url_query_param function docs
venuDreddy Aug 7, 2024
fc3cea4
Merge pull request #635 from permitio/oded/per-10422-fix-snyk-issues-…
roekatz Aug 7, 2024
d180532
Merge pull request #613 from permitio/snyk-fix-5f2cc54f1329582ac6c922…
roekatz Aug 7, 2024
607ed13
Dockerfile: Mitigate git vulnerability by disabling symlink support
roekatz Aug 7, 2024
a3e7785
Merge pull request #638 from permitio/rk/prevent-git-symlink-bug
roekatz Aug 7, 2024
0d7a39e
Per-9644 cicd fix pypi url (#639)
EliMoshkovich Aug 7, 2024
cb7eff8
Fix __packaging__.py format for pre-commit (#640)
roekatz Aug 7, 2024
fdf29bb
Merge pull request #637 from venuDreddy/typo/url-util
obsd Aug 12, 2024
2223e18
Rebase feature branch onto updated master
Jul 26, 2024
65c8302
Enable OAuth2 authentication.
Jun 25, 2024
f59f709
Hardcode peer_type = datasource
Jul 26, 2024
1b46d59
Rebase to master
Aug 6, 2024
e36a67e
Enable OAuth2 authentication.
Jun 25, 2024
c003453
Add Docker Compose examples with OAuth2 token validations
Aug 1, 2024
10ef61b
Remove unused imports
Aug 6, 2024
0ed5ae2
Enable OAuth2 authentication.
Jun 25, 2024
162bdcb
Enable OAuth2 authentication.
Jun 25, 2024
3553535
Rebase feature branch onto updated master
Jul 26, 2024
7b42622
Enable OAuth2 authentication.
Jun 25, 2024
1d1b4a2
Rebase to master
Aug 6, 2024
16e5fde
Enable OAuth2 authentication.
Jun 25, 2024
7100f97
Remove unused imports
Aug 6, 2024
806cd5b
Enable OAuth2 authentication.
Jun 25, 2024
47421cb
Enable OAuth2 authentication.
Jun 25, 2024
3621a9d
Enable OAuth2 authentication.
Jun 25, 2024
f260bcf
Merge remote-tracking branch 'origin/oauth2' into oauth2
Aug 15, 2024
016df4b
Rebase feature branch onto updated master
Jul 26, 2024
091c617
Enable OAuth2 authentication.
Jun 25, 2024
3dc7396
Rebase to master
Aug 6, 2024
608582f
Enable OAuth2 authentication.
Jun 25, 2024
00d8bee
Remove unused imports
Aug 6, 2024
41427f5
Enable OAuth2 authentication.
Jun 25, 2024
1451ff1
Enable OAuth2 authentication.
Jun 25, 2024
971da7f
Merge remote-tracking branch 'origin/oauth2' into oauth2
Aug 15, 2024
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
140 changes: 102 additions & 38 deletions .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ name: Build and publish to Docker Hub
on:
release:
# job will automatically run after a new "release" is create on github.
types: [created]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
dry_run:
description: 'If true, will not push the built images to docker hub.'
required: false
default: 'false'
types: [published]

jobs:
# this job will build, test and (potentially) push the docker images to docker hub
Expand All @@ -29,6 +21,12 @@ jobs:
# - Pushes images (built at BUILD PHASE) to docker hub.
docker_build_and_publish:
runs-on: ubuntu-latest
env:
github_token: ${{ secrets.TOKEN_GITHUB }}
permissions:
id-token: write
contents: write # 'write' access to repository contents
pull-requests: write # 'write' access to pull requests
steps:
# BUILD PHASE
- name: Checkout
Expand All @@ -43,25 +41,19 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true') }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get version tag from github release
if: github.event_name == 'release' && github.event.action == 'created'
run: |
echo "opal_version_tag=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- name: Get version tag from git history
if: ${{ !(github.event_name == 'release' && github.event.action == 'created') }}
- name: Docker Compose install
run: |
echo "opal_version_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

- name: Echo version tag
run: |
echo "The version tag that will be published to docker hub is: ${{ env.opal_version_tag }}"
echo "The version tag that will be published to docker hub is: ${{ github.event.release.tag_name }}"

- name: Build client for testing
id: build_client
Expand All @@ -76,19 +68,6 @@ jobs:
tags: |
permitio/opal-client:test

- name: Build client-standalone for testing
id: build_client_standalone
uses: docker/build-push-action@v4
with:
file: docker/Dockerfile
push: false
target: client-standalone
cache-from: type=registry,ref=permitio/opal-client-standalone:latest
cache-to: type=inline
load: true
tags: |
permitio/opal-client-standalone:test

- name: Build server for testing
id: build_server
uses: docker/build-push-action@v4
Expand Down Expand Up @@ -122,7 +101,6 @@ jobs:
# pushes the *same* docker images that were previously tested as part of e2e sanity test.
# each image is pushed with the versioned tag first, if it succeeds the image is pushed with the latest tag as well.
- name: Build & Push client
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true') }}
id: build_push_client
uses: docker/build-push-action@v4
with:
Expand All @@ -134,10 +112,9 @@ jobs:
cache-to: type=inline
tags: |
permitio/opal-client:latest
permitio/opal-client:${{ env.opal_version_tag }}
permitio/opal-client:${{ github.event.release.tag_name }}

- name: Build client-standalone
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true') }}
id: build_push_client_standalone
uses: docker/build-push-action@v4
with:
Expand All @@ -149,10 +126,9 @@ jobs:
cache-to: type=inline
tags: |
permitio/opal-client-standalone:latest
permitio/opal-client-standalone:${{ env.opal_version_tag }}
permitio/opal-client-standalone:${{ github.event.release.tag_name }}

- name: Build server
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true') }}
id: build_push_server
uses: docker/build-push-action@v4
with:
Expand All @@ -164,4 +140,92 @@ jobs:
cache-to: type=inline
tags: |
permitio/opal-server:latest
permitio/opal-server:${{ env.opal_version_tag }}
permitio/opal-server:${{ github.event.release.tag_name }}

- name: Build & Push client cedar
id: build_push_client_cedar
uses: docker/build-push-action@v4
with:
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: client-cedar
cache-from: type=registry,ref=permitio/opal-client-cedar:latest
cache-to: type=inline
tags: |
permitio/opal-client-cedar:latest
permitio/opal-client-cedar:${{ github.event.release.tag_name }}

- name: Python setup
uses: actions/setup-python@v5
with:
python-version: '3.11.8'

# This is the root file representing the package for all the sub-packages.
- name: Bump version - packaging__.py
run: |
version_tag=${{ github.event.release.tag_name }}
version_tag=${version_tag#v} # Remove the leading 'v'
version_tuple=$(echo $version_tag | sed 's/\./, /g')
sed -i "s/VERSION = (.*/VERSION = (${version_tuple})/" packages/__packaging__.py
cat packages/__packaging__.py

- name: Cleanup setup.py and Build every sub-packages
run: |
pip install wheel
cd packages/opal-common/ ; rm -rf *.egg-info build/ dist/
python setup.py sdist bdist_wheel
cd ../..
cd packages/opal-client/ ; rm -rf *.egg-info build/ dist/
python setup.py sdist bdist_wheel
cd ../..
cd packages/opal-server/ ; rm -rf *.egg-info build/ dist/
python setup.py sdist bdist_wheel
cd ../..

# Upload package distributions to the release - All assets in one step
- name: Upload assets to release
uses: shogo82148/[email protected]
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: |
packages/opal-common/dist/*
packages/opal-client/dist/*
packages/opal-server/dist/*

# Publish package distributions to PyPI
- name: Publish package distributions to PyPI - Opal-Common
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: packages/opal-common/dist/
# For Test only !
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
env:
name: pypi
url: https://pypi.org/p/opal-common/

- name: Publish package distributions to PyPI - Opal-Client
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: packages/opal-client/dist/
# For Test only !
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
env:
name: pypi
url: https://pypi.org/p/opal-client/

- name: Publish package distributions to PyPI - Opal-Server
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: packages/opal-server/dist/
# For Test only !
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
env:
name: pypi
url: https://pypi.org/p/opal-server/
65 changes: 65 additions & 0 deletions .github/workflows/sync_opal_plus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Sync branch to OPAL Plus

on:
push:
branches:
- master
workflow_dispatch:

jobs:
sync:
name: Sync branch to OPAL Plus
if: github.repository == 'permitio/opal'
runs-on: ubuntu-latest
steps:
- name: Set up Git configuration
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.APPLICATION_ID }}
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}

- name: Checkout permitio/opal repository
uses: actions/checkout@v4
with:
repository: permitio/opal
ref: ${{ github.ref_name }}
path: opal
fetch-depth: 0

- name: Checkout permitio/opal-plus repository
uses: actions/checkout@v4
with:
repository: permitio/opal-plus
path: opal-plus
token: ${{ steps.get_workflow_token.outputs.token }}

- name: Create public-${{ github.ref_name }} branch in opal repository
working-directory: opal
run: |
git checkout -b public-${{ github.ref_name }}

- name: Rebase opal-plus/public-${{ github.ref_name }} onto opal/${{ github.ref_name }}
working-directory: opal-plus
run: |
git remote add opal ../opal
git fetch opal
git checkout public-${{ github.ref_name }}
git rebase opal/${{ github.ref_name }}

- name: Push changes to opal-plus/public-${{ github.ref_name }} branch
working-directory: opal-plus
run: |
git push origin public-${{ github.ref_name }}

- name: Create Pull Request for opal-plus
working-directory: opal-plus
run: |
gh pr create --repo permitio/opal-plus --assignee "$GITHUB_ACTOR" --reviewer "$GITHUB_ACTOR" --base master --head public-${{ github.ref_name }} --title "Sync changes from public OPAL repository" --body "This PR synchronizes changes from the public OPAL repository to the private OPAL Plus repository."
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
8 changes: 7 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker Compose install
run: |
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

- name: Build client
id: build_client
uses: docker/build-push-action@v2
Expand Down Expand Up @@ -105,7 +110,8 @@ jobs:
- name: Output container logs
run: docker-compose -f docker/docker-compose-test.yml logs

- name: check if opal-client was brought up
- name: check if opal-client was brought up successfully
run: |
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep "Connected to PubSub server"
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep "Got policy bundle"
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep 'PUT /v1/data/static -> 204'
31 changes: 15 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BUILD STAGE ---------------------------------------
# split this stage to save time and reduce image size
# ---------------------------------------------------
FROM python:3.10-bookworm as BuildStage
FROM python:3.10-bookworm AS build-stage
# from now on, work in the /app directory
WORKDIR /app/
# Layer dependency install (for caching)
Expand All @@ -15,19 +15,17 @@ RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r ./
# CEDAR AGENT BUILD STAGE ---------------------------
# split this stage to save time and reduce image size
# ---------------------------------------------------
FROM rust:1.69.0 as cedar-builder
COPY cedar-agent /tmp/cedar-agent/
ARG cargo_flags="-r"
RUN cd /tmp/cedar-agent && \
cargo build ${cargo_flags} && \
cp /tmp/cedar-agent/target/*/cedar-agent /
FROM rust:1.79 AS cedar-builder
COPY ./cedar-agent /tmp/cedar-agent
WORKDIR /tmp/cedar-agent
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release

# COMMON IMAGE --------------------------------------
# ---------------------------------------------------
FROM python:3.10-slim-bookworm as common
FROM python:3.10-slim-bookworm AS common

# copy libraries from build stage (This won't copy redundant libraries we used in BuildStage)
COPY --from=BuildStage /usr/local /usr/local
# copy libraries from build stage (This won't copy redundant libraries we used in build-stage)
COPY --from=build-stage /usr/local /usr/local

# Add non-root user (with home dir at /opal)
RUN useradd -m -b / -s /bin/bash opal
Expand Down Expand Up @@ -61,7 +59,7 @@ CMD ["./start.sh"]

# STANDALONE IMAGE ----------------------------------
# ---------------------------------------------------
FROM common as client-standalone
FROM common AS client-standalone
# uvicorn config ------------------------------------
# install the opal-client package
RUN cd ./packages/opal-client && python setup.py install
Expand All @@ -88,7 +86,7 @@ VOLUME /opal/backup

# IMAGE to extract OPA from official image ----------
# ---------------------------------------------------
FROM alpine:latest as opa-extractor
FROM alpine:latest AS opa-extractor
USER root

RUN apk update && apk add skopeo tar
Expand All @@ -106,7 +104,7 @@ RUN skopeo copy "docker://${opa_image}:${opa_tag}" docker-archive:./image.tar &&
# OPA CLIENT IMAGE ----------------------------------
# Using standalone image as base --------------------
# ---------------------------------------------------
FROM client-standalone as client
FROM client-standalone AS client

# Temporarily move back to root for additional setup
USER root
Expand All @@ -123,13 +121,13 @@ USER opal
# CEDAR CLIENT IMAGE --------------------------------
# Using standalone image as base --------------------
# ---------------------------------------------------
FROM client-standalone as client-cedar
FROM client-standalone AS client-cedar

# Temporarily move back to root for additional setup
USER root

# Copy cedar from its build stage
COPY --from=cedar-builder /cedar-agent /bin/cedar-agent
COPY --from=cedar-builder /tmp/cedar-agent/target/*/cedar-agent /bin/cedar-agent

# enable inline Cedar agent
ENV OPAL_POLICY_STORE_TYPE=CEDAR
Expand All @@ -142,9 +140,10 @@ USER opal

# SERVER IMAGE --------------------------------------
# ---------------------------------------------------
FROM common as server
FROM common AS server

RUN apt-get update && apt-get install -y openssh-client git && apt-get clean
RUN git config --global core.symlinks false # Mitigate CVE-2024-32002

USER opal

Expand Down
Loading
Loading