Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvs committed Feb 29, 2024
1 parent 022dab4 commit a6f40e4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
If the tests are run by CI, we mock user infos here.
"""

import logging
from typing import Optional

Expand Down Expand Up @@ -87,7 +88,7 @@ def mock_user_for_ci():
"get_user_infos_from_access_token",
_mock_get_user_infos_from_access_token,
)
for (key, value) in [
for key, value in [
("FLAAT_ISS", _jwt_issuer),
("NON_JWT_FLAAT_ISS", _non_jwt_issuer),
("FLAAT_TRUSTED_OPS_LIST", [_jwt_issuer, _non_jwt_issuer]),
Expand Down
2 changes: 2 additions & 0 deletions examples/example_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def authorized_level(
match=1,
)


@app.get("/authorized_claim")
@flaat.requires(email_requirement)
def authorized_claim(
Expand All @@ -154,6 +155,7 @@ def authorized_claim(
match=2,
)


@app.get("/authorized_vo")
@flaat.requires(vo_requirement)
def authorized_vo(
Expand Down
12 changes: 7 additions & 5 deletions examples/example_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@

# Set a list of access levels to use
def is_admin(user_infos):
return user_infos.user_info['email'] in current_app.config['ADMIN_EMAILS']
return user_infos.user_info["email"] in current_app.config["ADMIN_EMAILS"]


flaat = Flaat([
AccessLevel("user", HasSubIss()),
AccessLevel("admin", IsTrue(is_admin)),
])
flaat = Flaat(
[
AccessLevel("user", HasSubIss()),
AccessLevel("admin", IsTrue(is_admin)),
]
)


class Config(object):
Expand Down
1 change: 1 addition & 0 deletions flaat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Python support for OIDC Access Tokens -- FLAAT.
Use decorators for authorising access to OIDC authenticated REST APIs.
"""

# This code is distributed under the MIT License

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions flaat/aio/overrides_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
FIXME The environment overrides in here are crude and will not work if run concurrently!
"""

import os
from typing import Optional

Expand Down
8 changes: 5 additions & 3 deletions flaat/flaat_userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,11 @@ def print_human_readable(self, args):

if self.user_infos.valid_for_secs is not None:
logger.info(
"Your token is valid for %s."
if self.user_infos.valid_for_secs > 0
else "Your token has EXPIRED for %s!",
(
"Your token is valid for %s."
if self.user_infos.valid_for_secs > 0
else "Your token has EXPIRED for %s!"
),
format_timespan(self.user_infos.valid_for_secs),
)

Expand Down
1 change: 1 addition & 0 deletions flaat/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
If you want to combine multiple requirements use the "meta requirements" :class:`AllOf` and :class:`N_Of`.
"""

import logging
from dataclasses import dataclass
from typing import Any, Callable, List, Optional, Union
Expand Down
1 change: 1 addition & 0 deletions flaat/tests/issuers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_valid_url_https_path(self):

def test_valid_url_https_port_path(self):
assert is_url("https://heise.de:9000/thi_s&is=difficult")

def test_short_url(self):
assert is_url("https://keycloak")

Expand Down

0 comments on commit a6f40e4

Please sign in to comment.