We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 756f640 commit a8f98d3Copy full SHA for a8f98d3
6 files changed
CHANGELOG.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8
+## [0.0.7] - 2021-01-31 :grapes:
9
+- Corrects a bug in the `Policy` class (#2)
10
+- Changes the type annotation of `Identity` claims (#3)
11
+
12
## [0.0.6] - 2020-12-12 :octocat:
13
- Completely migrates to GitHub Workflows
14
- Improves build to test Python 3.6 and 3.9
README.md
@@ -53,3 +53,9 @@ do something?_.
53
Usually, to implement authorization, is necessary to have the context of the
54
entity that is executing the action. Anyway, the two things are logically
55
separated and GuardPost is designed to keep them separate.
56
57
+## Usage in BlackSheep
58
+`guardpost` is used in the [BlackSheep](https://www.neoteroi.dev/blacksheep/)
59
+web framework to implement [authentication and authorization
60
+strategies](https://www.neoteroi.dev/blacksheep/authentication/) for request
61
+handlers.
guardpost/authentication.py
@@ -1,11 +1,11 @@
1
from abc import ABC
2
-from typing import Any, Dict, Optional, Sequence
+from typing import Optional, Sequence
3
4
class Identity:
def __init__(
self,
- claims: Dict[Any, Any],
+ claims: dict,
authentication_mode: Optional[str] = None,
):
self.claims = claims or {}
guardpost/authorization.py
@@ -90,8 +90,10 @@ def forced_failure(self) -> Optional[str]:
90
return self._failed_forced
91
92
def fail(self, reason: str):
93
- """Called to indicate that this authorization context has failed.
94
- Forces failure, regardless of succeeded requirements."""
+ """
+ Called to indicate that this authorization context has failed.
95
+ Forces failure, regardless of succeeded requirements.
96
97
self._failed_forced = reason or "Authorization failed."
98
99
def __enter__(self):
@@ -115,7 +117,7 @@ class Policy:
115
117
116
118
def __init__(self, name: str, *requirements: BaseRequirement):
119
self.name = name
- self.requirements = requirements or []
120
+ self.requirements = list(requirements) or []
121
122
def add(self, requirement: BaseRequirement) -> "Policy":
123
self.requirements.append(requirement)
guardpost/common.py
@@ -1,7 +1,9 @@
-from typing import Sequence, Union, Mapping as MappingType
from collections.abc import Mapping
+from typing import Mapping as MappingType
+from typing import Sequence, Union
from .authorization import Policy
-from .synchronous.authorization import Requirement, AuthorizationContext
+from .synchronous.authorization import AuthorizationContext, Requirement
class AnonymousRequirement(Requirement):
setup.py
@@ -8,13 +8,13 @@ def readme():
setup(
name="guardpost",
- version="0.0.6",
+ version="0.0.7",
description="Basic framework to handle authentication and authorization "
+ "in any kind of Python application.",
long_description=readme(),
15
long_description_content_type="text/markdown",
16
classifiers=[
17
- "Development Status :: 3 - Alpha",
+ "Development Status :: 5 - Production/Stable",
18
"License :: OSI Approved :: MIT License",
19
"Programming Language :: Python :: 3",
20
"Programming Language :: Python :: 3.6",
@@ -23,7 +23,7 @@ def readme():
23
"Programming Language :: Python :: 3.9",
24
"Operating System :: OS Independent",
25
],
26
- url="https://github.com/Neoteroi/GuardPost",
+ url="https://github.com/Neoteroi/guardpost",
27
author="Roberto Prevato",
28
author_email="roberto.prevato@gmail.com",
29
keywords="authentication authorization identity claims strategy "
0 commit comments