Skip to content

Commit a8f98d3

Browse files
v0.0.7 🍇
1 parent 756f640 commit a8f98d3

6 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

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+
812
## [0.0.6] - 2020-12-12 :octocat:
913
- Completely migrates to GitHub Workflows
1014
- Improves build to test Python 3.6 and 3.9

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ do something?_.
5353
Usually, to implement authorization, is necessary to have the context of the
5454
entity that is executing the action. Anyway, the two things are logically
5555
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from abc import ABC
2-
from typing import Any, Dict, Optional, Sequence
2+
from typing import Optional, Sequence
33

44

55
class Identity:
66
def __init__(
77
self,
8-
claims: Dict[Any, Any],
8+
claims: dict,
99
authentication_mode: Optional[str] = None,
1010
):
1111
self.claims = claims or {}

guardpost/authorization.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ def forced_failure(self) -> Optional[str]:
9090
return self._failed_forced
9191

9292
def fail(self, reason: str):
93-
"""Called to indicate that this authorization context has failed.
94-
Forces failure, regardless of succeeded requirements."""
93+
"""
94+
Called to indicate that this authorization context has failed.
95+
Forces failure, regardless of succeeded requirements.
96+
"""
9597
self._failed_forced = reason or "Authorization failed."
9698

9799
def __enter__(self):
@@ -115,7 +117,7 @@ class Policy:
115117

116118
def __init__(self, name: str, *requirements: BaseRequirement):
117119
self.name = name
118-
self.requirements = requirements or []
120+
self.requirements = list(requirements) or []
119121

120122
def add(self, requirement: BaseRequirement) -> "Policy":
121123
self.requirements.append(requirement)

guardpost/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from typing import Sequence, Union, Mapping as MappingType
21
from collections.abc import Mapping
2+
from typing import Mapping as MappingType
3+
from typing import Sequence, Union
4+
35
from .authorization import Policy
4-
from .synchronous.authorization import Requirement, AuthorizationContext
6+
from .synchronous.authorization import AuthorizationContext, Requirement
57

68

79
class AnonymousRequirement(Requirement):

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ def readme():
88

99
setup(
1010
name="guardpost",
11-
version="0.0.6",
11+
version="0.0.7",
1212
description="Basic framework to handle authentication and authorization "
1313
+ "in any kind of Python application.",
1414
long_description=readme(),
1515
long_description_content_type="text/markdown",
1616
classifiers=[
17-
"Development Status :: 3 - Alpha",
17+
"Development Status :: 5 - Production/Stable",
1818
"License :: OSI Approved :: MIT License",
1919
"Programming Language :: Python :: 3",
2020
"Programming Language :: Python :: 3.6",
@@ -23,7 +23,7 @@ def readme():
2323
"Programming Language :: Python :: 3.9",
2424
"Operating System :: OS Independent",
2525
],
26-
url="https://github.com/Neoteroi/GuardPost",
26+
url="https://github.com/Neoteroi/guardpost",
2727
author="Roberto Prevato",
2828
author_email="roberto.prevato@gmail.com",
2929
keywords="authentication authorization identity claims strategy "

0 commit comments

Comments
 (0)