Skip to content
Open
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
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/linty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
paths:
- '*.py'

jobs:
flake8_py3:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.11.4
architecture: x64
- name: Checkout PyTorch
uses: actions/checkout@master
- name: Install flake8
run: pip install flake8
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'flake8_py3' # NOTE: this needs to be the same as the job name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- DJANGO_VERSION=1.11
- DJANGO_VERSION=2.0
- DJANGO_VERSION=4.1
- DJANGO_VERSION=4.2
addons:
sonarcloud:
organization: $SC_ORG
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
install-python:
pip install --upgrade setuptools
pip install -e .
pip install "file://`pwd`#egg=django-keycloak[dev,doc]"
# pyenv virtualenv 3.11.4 django-keycloak || pyenv activate django-keycloak
pip install --upgrade setuptools poethepoet
poe install
poe addsudo "file://`pwd`#egg=django-keycloak[dev,doc]"

bump-patch:
bumpversion patch
poetry version patch

bump-minor:
bumpversion minor
poetry version minor

deploy-pypi: clear
python3 -c "import sys; sys.version_info >= (3, 5, 3) or sys.stdout.write('Python version must be greatest then 3.5.2\n') or exit(1)"
python3 setup.py sdist bdist_wheel
twine upload dist/*
poetry build
poetry publish

clear:
rm -rf dist/*
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
Django Keycloak
===============

.. image:: https://www.travis-ci.org/Peter-Slump/django-keycloak.svg?branch=master
:target: https://www.travis-ci.org/Peter-Slump/django-keycloak
.. image:: https://www.travis-ci.org/skamansam/django-keycloak.svg?branch=master
:target: https://www.travis-ci.org/skamansam/django-keycloak
:alt: Build Status
.. image:: https://readthedocs.org/projects/django-keycloak/badge/?version=latest
:target: http://django-keycloak.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://codecov.io/gh/Peter-Slump/django-keycloak/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Peter-Slump/django-keycloak
.. image:: https://codecov.io/gh/skamansam/django-keycloak/branch/master/graph/badge.svg
:target: https://codecov.io/gh/skamansam/django-keycloak
:alt: codecov
.. image:: https://api.codeclimate.com/v1/badges/eb19f47dc03dec40cea7/maintainability
:target: https://codeclimate.com/github/Peter-Slump/django-keycloak/maintainability
:target: https://codeclimate.com/github/skamansam/django-keycloak/maintainability
:alt: Maintainability

Django app to add Keycloak support to your project.
Expand Down Expand Up @@ -72,6 +72,7 @@ Release Notes
=============

**unreleased**
**v0.1.2**

**v0.2.5**

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 29 additions & 14 deletions example/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,42 @@ services:
- resource-provider-api

keycloak:
image: jboss/keycloak:3.4.3.Final # Pinned to 3.4.3 because this is currently the latest version which has commercial support from Red Hat: https://www.keycloak.org/support.html
# build: ./keycloak
image: quay.io/keycloak/keycloak:latest
command: [
"-b", "0.0.0.0",
"-Dkeycloak.migration.action=import", # Replace with 'export' in order to export everything
"-Dkeycloak.migration.provider=dir",
"-Dkeycloak.migration.dir=/opt/jboss/keycloak/standalone/configuration/export/",
"-Dkeycloak.migration.strategy=IGNORE_EXISTING"
"start-dev",
# "--help",
# "-b", "0.0.0.0",
"--import-realm",
"--log-level=debug",
"--metrics-enabled=true",
"--db=postgres",
"--db-url=postgres:5432",
"--db-username=keycloak",
"--db-password=keycloak",
"--db-schema=keycloak",
# "--verbose",
# "-Dkeycloak.migration.action=import", # Replace with 'export' in order to export everything
# "-Dkeycloak.migration.provider=dir",
# "-Dkeycloak.migration.dir=/opt/keycloak/data/import",
# "-Dkeycloak.migration.strategy=IGNORE_EXISTING"
]
environment:
- POSTGRES_DATABASE=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=password
- KC_METRICS_ENABLED=true
# - POSTGRES_DATABASE=keycloak
# - POSTGRES_USER=keycloak
# - POSTGRES_PASSWORD=password
- KEYCLOAK_HOSTNAME=identity.localhost.yarf.nl
# Legacy linking functionality is used
- POSTGRES_PORT_5432_TCP_ADDR=postgres
- POSTGRES_PORT_5432_TCP_PORT=5432
# # Legacy linking functionality is used
# - POSTGRES_PORT_5432_TCP_ADDR=postgres
# - POSTGRES_PORT_5432_TCP_PORT=5432
- PROXY_ADDRESS_FORWARDING=true
- KEYCLOAK_LOGLEVEL=DEBUG
# - JAVA_TOOL_OPTIONS=-Dkeycloak.profile.feature.admin_fine_grained_authz=enabled -Dkeycloak.profile.feature.token_exchange=enabled # Required to enable Token exchange feature in newer versions of Keycloak
# - KEYCLOAK_ADMIN=admin
# - KEYCLOAK_ADMIN_PASSWORD=admin
# # - JAVA_TOOL_OPTIONS=-Dkeycloak.profile.feature.admin_fine_grained_authz=enabled -Dkeycloak.profile.feature.token_exchange=enabled # Required to enable Token exchange feature in newer versions of Keycloak
volumes:
- ./keycloak/export:/opt/jboss/keycloak/standalone/configuration/export
- ./keycloak/export:/opt/keycloak/data/import/
networks:
default:
aliases:
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Install requirement.

.. code-block:: bash

$ pip install git+https://github.com/Peter-Slump/django-keycloak.git
$ pip install git+https://github.com/skamansam/django-keycloak.git

Setup
=====
Expand Down Expand Up @@ -85,7 +85,7 @@ add the middleware, configure the urls and point to the correct login page.
urlpatterns = [
...

url(r'^keycloak/', include('django_keycloak.urls')),
path('keycloak/', include('django_keycloak.urls')),
]


Expand Down
24 changes: 24 additions & 0 deletions example/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM quay.io/keycloak/keycloak:latest as builder

# Enable health and metrics support
# ENV KC_HEALTH_ENABLED=true
# ENV KC_METRICS_ENABLED=true

# Configure a database vendor
# ENV KC_DB=postgres

WORKDIR /opt/keycloak
# for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/

# change these values to point to a running postgres instance
# ENV KC_DB=postgres
# ENV KC_DB_URL=localhost:5432
# ENV KC_DB_USERNAME=admin
# ENV KC_DB_PASSWORD=admin
# ENV KC_HOSTNAME=localhost
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
11 changes: 5 additions & 6 deletions example/resource-provider-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM python:3-alpine
FROM python:3.11.4-alpine

RUN apk update \
&& apk add git openssl-dev libffi-dev python-dev build-base
&& apk add git openssl-dev libffi-dev build-base \
&& pip install poethepoet poetry

RUN mkdir -p /usr/src/app
COPY ./poetry.lock ./pyproject.toml /usr/src/app/

WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/

RUN pip install --no-cache-dir -r requirements.txt
RUN poetry install

COPY . /usr/src/app

Expand Down
8 changes: 4 additions & 4 deletions example/resource-provider-api/myapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.urls import include, path
from django.contrib import admin

from myapp import views


urlpatterns = [
url(r'^api/end-point$', views.api_end_point),
url(r'^api/authenticated-end-point$', views.authenticated_end_point),
url(r'^admin/', admin.site.urls),
path(r'api/end-point', views.api_end_point),
path(r'api/authenticated-end-point', views.authenticated_end_point),
path(r'admin/', admin.site.urls),
]
85 changes: 85 additions & 0 deletions example/resource-provider-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions example/resource-provider-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "resource-provider-api"
version = "0.1.0"
description = "api provider for django-keycloak example"
authors = ["Samuel C. Tyler <[email protected]>"]
# readme = "README.md"
# packages = [{include = "resource_provider"}]

[tool.poetry.dependencies]
python = "^3.11"
Django = "^4.2.4"

[tool.poetry.group.dev.dependencies]
django-dynamic-fixtures = "^0.2.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion example/resource-provider-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
django>=2.0.10
git+git://github.com/Peter-Slump/django-keycloak.git#egg=django-keycloak
git+git://github.com/skamansam/django-keycloak.git#egg=django-keycloak
django-dynamic-fixtures==0.1.7
11 changes: 5 additions & 6 deletions example/resource-provider/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM python:3-alpine
FROM python:3.11.4-alpine

RUN apk update \
&& apk add git openssl-dev libffi-dev python-dev build-base
&& apk add git openssl-dev libffi-dev build-base \
&& pip install poethepoet poetry

RUN mkdir -p /usr/src/app
COPY ./poetry.lock ./pyproject.toml /usr/src/app/

WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/

RUN pip install --no-cache-dir -r requirements.txt
RUN poetry install

COPY . /usr/src/app

Expand Down
3 changes: 3 additions & 0 deletions example/resource-provider/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import os
import sys

sys.path.append(os.path.abspath('../../src'))
print(sys.path)

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
try:
Expand Down
Loading