Skip to content

Commit

Permalink
Merge pull request #2 from OpenRailAssociation/api-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmehl authored Feb 28, 2025
2 parents 7eb8596 + 23c3707 commit bb982bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ auth-user-mgr sync --help

The application's configuration and the list of managed users are stored in YAML files. You can find sample configuration files in the [`config/`](./config/) directory.

#### API permissions

Especially for automated syncs, it is recommended to set up a system user in Authentik and create an API token for them. The following permissions are required:

- User: Can view User
- Group: Can view Group
- Group: Add user to group
- Group: Remove user from group
- Flow: Can view Flow
- Invitation: Can view Invitation
- Invitation: Can add Invitation
- Invitation: Can delete Invitation


## Development and Contribution

Expand Down
10 changes: 10 additions & 0 deletions auth_user_mgr/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def api_call( # pylint: disable=too-many-positional-arguments, too-many-argumen
else:
raise ValueError(f"Invalid method: {method}")

if response.status_code not in range(200, 300):
logging.error(
"API call '%s %s' with data '%s' exited with a non 2xx status code (%s): %s",
method,
url,
data,
response.status_code,
response.text,
)

# Convert response JSON to dict
try:
result: dict = json.loads(response.text)
Expand Down

0 comments on commit bb982bb

Please sign in to comment.