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

added functionality for scope base permission and group based policies #430

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e013b18
added create_client_authz_group_based_policy, create_client_authz_sco…
Apr 12, 2023
6ef75fe
added update_client_authz_role_based_policy, update_client_authz_grou…
Apr 13, 2023
2eae560
forgot to push urls
Apr 13, 2023
cde8b14
added update_resource_server
Apr 24, 2023
ffe3204
test: fixed tests for new keycloak (#438)
ryshoooo Apr 28, 2023
e0c2725
fix(pyproject.toml): loose requests pgk and remove urllib3 as depende…
karimelhajoui63 Apr 28, 2023
85855e6
docs: changelog update
ryshoooo Apr 28, 2023
a7407cd
feat: Add get and delete methods for client authz resources (#435)
sras1599 Apr 28, 2023
7711fe4
docs: changelog update
ryshoooo Apr 28, 2023
d0f1080
fix: Initializing KeycloakAdmin without server_url (#439)
arminshoughi May 1, 2023
8814991
docs: changelog update
ryshoooo May 1, 2023
c289ed6
docs: Fixed a typo (#441)
michitaro May 8, 2023
d80b855
fix: issue with app engine reported in #440 (#442)
isccarrasco May 9, 2023
50ad533
docs: changelog update
ryshoooo May 9, 2023
b5e1904
fix: Fixes `Authorization.load_config` breaking if a scope based perm…
sras1599 May 15, 2023
fcf521f
docs: changelog update
ryshoooo May 15, 2023
89a6082
perf: improve performance of get_user_id (#449)
mjeanroy May 28, 2023
a0ed022
docs: changelog update
ryshoooo May 28, 2023
fe31e7d
fix: do not swap realm for user_realm when logging in with a client s…
gboor May 28, 2023
ad3f898
docs: changelog update
ryshoooo May 28, 2023
b9bacdb
fix: relax the version constraints
ryshoooo-adamatics May 28, 2023
06d320a
chore: bump the deprecation to v4
ryshoooo-adamatics May 28, 2023
803aa3d
ci: include the package
ryshoooo-adamatics May 28, 2023
a179569
docs: changelog update
ryshoooo May 28, 2023
d247539
refactor: Exchange token method
AndreasBBS May 28, 2023
9cf0577
docs: changelog update
ryshoooo May 28, 2023
00521ea
feat: Add query to get users group method and permit pagination (#444)
anapaulamendes Jun 23, 2023
223eeaa
docs: changelog update
ryshoooo Jun 23, 2023
683d021
test: fix the user group pagination test
ryshoooo Jun 23, 2023
4add676
test: fix the token test
ryshoooo Jun 23, 2023
7a87fac
chore: deps update
ryshoooo Jun 23, 2023
b7ec87e
fix: remove duplicate slash in URL_ADMIN_IDP (#459)
jasminapegan Jun 23, 2023
6146010
docs: changelog update
ryshoooo Jun 23, 2023
e802222
feat: Implement missing admin method create_client_authz_scope_based_…
cainotis Jun 23, 2023
a9b364e
docs: changelog update
ryshoooo Jun 23, 2023
2e2735a
feat: added KeycloakAdmin.update_client_authz_resource() (#462)
cainotis Jun 27, 2023
66eae8e
docs: changelog update
ryshoooo Jun 27, 2023
c087ebf
feat: add an optional search criteria to the get_realm_roles function…
SalemWafi Nov 13, 2023
8bd71e0
docs: changelog update
ryshoooo Nov 13, 2023
ca8cfb3
chore: Add direct "setuptools" dependency (#505)
pehala Nov 13, 2023
e579296
chore: make audience in token exchange optional (#499)
pitwegner Nov 13, 2023
17ad531
chore: Add typing to Keycloak admin connection (#496)
jackylamhk Nov 13, 2023
67d888c
chore: add typing for KeycloakAdmin connection attribute (#492)
Kevin-Bannier Nov 13, 2023
a082cc9
feat: Update dynamic client using registration access token (#491)
mklassen Nov 13, 2023
b158c6a
docs: Allow the verify attribute to be bool or string #479 (#480)
waza-ari Nov 13, 2023
37fc295
docs: changelog update
ryshoooo Nov 13, 2023
e272547
feat: add KeycloakAdmin.get_idp() (#478)
derlin Nov 13, 2023
cb6f8d2
docs: changelog update
ryshoooo Nov 13, 2023
a724051
chore: Feat/create permission for scopes (#400)
Hadeer-Elsaeed Nov 13, 2023
6885ada
chore: implement get_realm_role_groups method (#464)
enzossatolo Nov 13, 2023
8d5942b
chore: implement partialImport request (#456)
Ujifman Nov 13, 2023
0f43cee
chore: add missing get_realm_role_by_id to KeycloakAdmin (#468)
cainotis Nov 13, 2023
a9180de
chore: loosen requests-toolbelt dependency (#473)
mnaser Nov 13, 2023
71442ab
docs: Remove removed function attribute from README.md (#469)
vitorespindola Nov 13, 2023
3bcc0a1
chore: Feat/support admin events (#474)
zimaldone Nov 13, 2023
73af7b9
chore: Add device authorization grant (#454)
manonmichel Nov 13, 2023
dee59c6
fix: Ci/fix tests (#506)
ryshoooo Nov 13, 2023
734ecf5
docs: changelog update
ryshoooo Nov 13, 2023
78b3e9e
fix: no prints
ryshoooo Nov 13, 2023
8ad784c
feat: realm changing helpers
ryshoooo Nov 13, 2023
1e74b43
docs: changelog update
ryshoooo Nov 13, 2023
026e3c0
added create_client_authz_group_based_policy, create_client_authz_sco…
Apr 12, 2023
563e7e6
added get_child_groups
Jan 8, 2024
6a8831b
added pagination to get_child_groups
Jan 9, 2024
80a6c94
fixed wrong url in get_child_groups
Jan 9, 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
4 changes: 2 additions & 2 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
keycloak-version: ["20.0", "21.0", "latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
keycloak-version: ["20.0", "21.0", "22.0", "latest"]
env:
KEYCLOAK_DOCKER_IMAGE_TAG: ${{ matrix.keycloak-version }}
steps:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: webiny/action-conventional-commits@v1.0.3
- uses: webiny/action-conventional-commits@v1.1.0

check-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -37,10 +37,10 @@ jobs:
- check-linting
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -55,8 +55,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
keycloak-version: ["20.0", "21.0", "latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
keycloak-version: ["20.0", "21.0", "22.0", "latest"]
needs:
- check-commits
- check-linting
Expand Down Expand Up @@ -88,10 +88,10 @@ jobs:
- check-docs
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.10"
python: "3.12"
jobs:
post_install:
- pip install -U poetry
Expand Down
138 changes: 129 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
## v3.7.0 (2023-11-13)

### Feat

- realm changing helpers

### Fix

- no prints

## v3.6.1 (2023-11-13)

### Fix

- Ci/fix tests (#506)

## v3.6.0 (2023-11-13)

### Feat

- add KeycloakAdmin.get_idp() (#478)

## v3.5.0 (2023-11-13)

### Feat

- Update dynamic client using registration access token (#491)

## v3.4.0 (2023-11-13)

### Feat

- add an optional search criteria to the get_realm_roles function (#504)

## v3.3.0 (2023-06-27)

### Feat

- added KeycloakAdmin.update_client_authz_resource() (#462)

## v3.2.0 (2023-06-23)

### Feat

- Implement missing admin method create_client_authz_scope_based_permission() and create_client_authz_policy() (#460)

## v3.1.1 (2023-06-23)

### Fix

- remove duplicate slash in URL_ADMIN_IDP (#459)

## v3.1.0 (2023-06-23)

### Feat

- Add query to get users group method and permit pagination (#444)

## v3.0.0 (2023-05-28)

### BREAKING CHANGE

- Changes the exchange token API

### Refactor

- Exchange token method

## v2.16.6 (2023-05-28)

### Fix

- relax the version constraints

## v2.16.5 (2023-05-28)

### Fix

- do not swap realm for user_realm when logging in with a client service account (#447)

## v2.16.4 (2023-05-28)

### Perf

- improve performance of get_user_id (#449)

## v2.16.3 (2023-05-15)

### Fix

- Fixes `Authorization.load_config` breaking if a scope based permission is linked with anything other than a role based policy. Fixes #445 (#446)

## v2.16.2 (2023-05-09)

### Fix

- issue with app engine reported in #440 (#442)

## v2.16.1 (2023-05-01)

### Fix

- Initializing KeycloakAdmin without server_url (#439)

## v2.16.0 (2023-04-28)

### Feat

- Add get and delete methods for client authz resources (#435)

## v2.15.4 (2023-04-28)

### Fix

- **pyproject.toml**: loose requests pgk and remove urllib3 as dependency (#434)

## v2.15.3 (2023-04-06)

### Fix
Expand Down Expand Up @@ -72,13 +188,16 @@

## v2.11.0 (2023-02-08)

### Feat

- Add Client Scopes of Client

## v2.10.0 (2023-02-08)

### Feat

- update header if token is given
- init KeycloakAdmin with token
- Add Client Scopes of Client

## v2.9.0 (2023-01-11)

Expand Down Expand Up @@ -127,12 +246,15 @@

## v2.5.0 (2022-08-19)

### Feat

- added missing functionality to include attributes when returning realm roles according to specifications

## v2.4.0 (2022-08-19)

### Feat

- add client scope-mappings client roles operations
- added missing functionality to include attributes when returning realm roles according to specifications

## v2.3.0 (2022-08-13)

Expand Down Expand Up @@ -251,8 +373,8 @@

### Feat

- Add get_idp_mappers, fix #329
- Support Token Exchange. Fixes #305
- Add get_idp_mappers, fix #329

## v1.1.1 (2022-05-27)

Expand Down Expand Up @@ -292,16 +414,16 @@

## v0.29.0 (2022-05-23)

### Feat

- added UMA-permission request functionality

### Fix

- added fixes based on feedback

## v0.28.3 (2022-05-23)

### Feat

- added UMA-permission request functionality

### Fix

- import classes in the base module
Expand All @@ -320,8 +442,6 @@

## v0.28.0 (2022-05-19)

## v (2022-05-19)

### Feat

- added authenticator providers getters
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ certs = keycloak_openid.certs()
token = keycloak_openid.token("user", "password")
rpt = keycloak_openid.entitlement(token['access_token'], "resource_id")

# Instropect RPT
# Introspect RPT
token_rpt_info = keycloak_openid.introspect(keycloak_openid.introspect(token['access_token'], rpt=rpt['rpt'],
token_type_hint="requesting_party_token"))

Expand Down Expand Up @@ -249,6 +249,9 @@ client = keycloak_admin.get_client(client_id="client_id")
# Get all roles for the realm or client
realm_roles = keycloak_admin.get_realm_roles()

# Get all roles for the realm or client that their names includes the searched text
realm_roles = keycloak_admin.get_realm_roles(search_text="CompanyA_")

# Get all roles for the client
client_roles = keycloak_admin.get_client_roles(client_id="client_id")

Expand Down Expand Up @@ -303,7 +306,7 @@ groups = keycloak_admin.get_groups()
group = keycloak_admin.get_group(group_id='group_id')

# Get group by name
group = keycloak_admin.get_group_by_path(path='/group/subgroup', search_in_subgroups=True)
group = keycloak_admin.get_group_by_path(path='/group/subgroup')

# Function to trigger user sync from provider
sync_users(storage_id="storage_di", action="action")
Expand Down Expand Up @@ -337,19 +340,35 @@ keycloak_admin.get_client_roles_of_client_scope(client_id=another_client_id, cli
# Remove client roles assigned to client's scope
keycloak_admin.delete_client_roles_of_client_scope(client_id=another_client_id, client_roles_owner_id=client_id, roles=client_roles)

# Get all ID Providers
# Get all IDP Providers
idps = keycloak_admin.get_idps()

# Get a specific IDP Provider, using its alias
idp = keycloak_admin.get_idp("idp-alias")

# Create a new Realm
keycloak_admin.create_realm(payload={"realm": "demo"}, skip_exists=False)

# Changing Realm
keycloak_admin = KeycloakAdmin(realm_name="main", ...)
keycloak_admin.get_users() # Get user in main realm
keycloak_admin.realm_name = "demo" # Change realm to 'demo'
keycloak_admin.change_current_realm("demo") # Change realm to 'demo'
keycloak_admin.get_current_realm() # Gives 'demo'
keycloak_admin.get_users() # Get users in realm 'demo'
keycloak_admin.create_user(...) # Creates a new user in 'demo'

# Get User events
keycloak_admin.get_events(query={'type': 'LOGIN',
'user': user['id'],
'dateFrom': '2023-08-02'})

# Get Admin events
keycloak_admin.get_admin_events(query={'resourceTypes': 'USER',
'operationTypes': 'UPDATE',
'resourcePath': 'users/' + user['id'],
'dateFrom': '2023-08-02'
})

# KEYCLOAK UMA

from keycloak import KeycloakOpenIDConnection
Expand Down
Loading