generated from anoadragon453/nio-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from elokapina/jaywink/users-command
Add command `users`
- Loading branch information
Showing
8 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
HELP_USERS = """List or manage users. | ||
Without any subcommands, lists users. Actually that's the only thing it does for now :P | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
matrix-nio[e2e]>=0.8.0 | ||
Markdown>=3.1.1 | ||
python-keycloak>=0.24.0 | ||
PyYAML>=5.1.2 | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import List, Dict | ||
|
||
# noinspection PyPackageRequirements | ||
from keycloak import KeycloakAdmin | ||
|
||
from config import Config | ||
|
||
|
||
def get_admin_client(config: Config) -> KeycloakAdmin: | ||
params = { | ||
"server_url": config.users["provider"]["url"], | ||
"realm_name": config.users["provider"]["realm_name"], | ||
"client_secret_key": config.users["provider"]["client_secret_key"], | ||
"verify": True, | ||
} | ||
return KeycloakAdmin(**params) | ||
|
||
|
||
async def list_users(config: Config) -> List[Dict]: | ||
if not config.users.get('provider'): | ||
return [] | ||
keycloak_admin = get_admin_client(config) | ||
users = keycloak_admin.get_users({}) | ||
return users |