Skip to content

Commit

Permalink
Enhancements in docstrings
Browse files Browse the repository at this point in the history
Added more legibel documentation to the docstrings of the functions and added mroe examples about how to use them
  • Loading branch information
dmtzs committed Dec 19, 2023
1 parent 764cf5e commit 1888d52
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions src/flask_authgen_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ def personal_credentials_field(self, func: Callable[[None], tuple[str, str]]) ->
:param func: function to be decorated
:return: the tuple with the username and password with personal names
:Example:
### Example
```python
@dec_jwt.personal_credentials_field
def get_personal_credentials():
return "my_username_personal_name_field", "my_password_personal_name_field"
```
"""
self.personal_credentials = func()
return func
Expand Down Expand Up @@ -322,9 +323,35 @@ def __set_token_as_attr(self, token: dict) -> None:
self.token = token

def get_jwt_claims_to_verify(self, func: Callable[[None], list[str]]) -> None:
"""Decorator to get the claims to verify in the token
:param func: function to be decorated, should return a list of the claims to verify
:return: the function to wrap that returns the a boolean field"""
"""
Decorator to get the claims to verify in the token
Args:
- func: function to be decorated, should return a list of the claims to verify
Returns:
- Callable: the function to wrap that returns the a boolean field
### Registered claims
The JWT specification defines seven reserved claims that are not required, but are recommended to allow interoperability with third-party applications. These are:
- iss (issuer): Issuer of the JWT
- sub (subject): Subject of the JWT (the user)
- aud (audience): Recipient for which the JWT is intended
- exp (expiration time): Time after which the JWT expires
- nbf (not before time): Time before which the JWT must not be accepted for processing
- iat (issued at time): Time at which the JWT was issued; can be used to determine age of the JWT
- jti (JWT ID): Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only once)
More about claims [here](https://auth0.com/docs/secure/tokens/json-web-tokens/json-web-token-claims)
### Example
```python
@dec_jwt.get_jwt_claims_to_verify
def get_jwt_claims():
return ["iat", "sub"]
```
"""
self.get_jwt_claims_to_verify_callback = func()

def verify_jwt_credentials(self, func: Callable[[str, str], bool]) -> Callable[[str, str], bool]:
Expand Down

0 comments on commit 1888d52

Please sign in to comment.