New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

Authlib

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Authlib - pypi Package Compare versions

Comparing version
1.6.5
to
1.6.6
+1
-1
Authlib.egg-info/PKG-INFO
Metadata-Version: 2.4
Name: Authlib
Version: 1.6.5
Version: 1.6.6
Summary: The ultimate Python library in building OAuth and OpenID Connect servers and clients.

@@ -5,0 +5,0 @@ Author-email: Hsiaoming Yang <me@lepture.com>

@@ -1,2 +0,3 @@

"""authlib.
"""
authlib
~~~~~~~

@@ -3,0 +4,0 @@

name = "Authlib"
version = "1.6.5"
version = "1.6.6"
author = "Hsiaoming Yang <me@lepture.com>"

@@ -4,0 +4,0 @@ homepage = "https://authlib.org"

@@ -23,7 +23,5 @@ import json

now = time.time()
prefix = f"_state_{self.name}"
for key in dict(session):
if "_authlib_" in key:
# TODO: remove in future
session.pop(key)
elif key.startswith("_state_"):
if key.startswith(prefix):
value = session[key]

@@ -36,8 +34,11 @@ exp = value.get("exp")

key = f"_state_{self.name}_{state}"
session_data = session.get(key)
if not session_data:
return None
if self.cache:
value = self._get_cache_data(key)
cached_value = self._get_cache_data(key)
else:
value = session.get(key)
if value:
return value.get("data")
cached_value = session_data
if cached_value:
return cached_value.get("data")
return None

@@ -47,6 +48,7 @@

key = f"_state_{self.name}_{state}"
now = time.time()
if self.cache:
self.cache.set(key, json.dumps({"data": data}), self.expires_in)
session[key] = {"exp": now + self.expires_in}
else:
now = time.time()
session[key] = {"data": data, "exp": now + self.expires_in}

@@ -58,5 +60,4 @@

self.cache.delete(key)
else:
session.pop(key, None)
self._clear_session_state(session)
session.pop(key, None)
self._clear_session_state(session)

@@ -63,0 +64,0 @@ def update_token(self, token, refresh_token=None, access_token=None):

@@ -175,2 +175,4 @@ import base64

headers["Content-Type"] = CONTENT_TYPE_FORM_URLENCODED
if isinstance(body, bytes):
body = body.decode()
uri, headers, body = self.sign(method, uri, headers, body)

@@ -177,0 +179,0 @@ elif self.force_include_body:

@@ -7,5 +7,13 @@ import time

if params.get("expires_at"):
params["expires_at"] = int(params["expires_at"])
try:
params["expires_at"] = int(params["expires_at"])
except ValueError:
# If expires_at is not parseable, fall back to expires_in if available
# Otherwise leave expires_at untouched
if params.get("expires_in"):
params["expires_at"] = int(time.time()) + int(params["expires_in"])
elif params.get("expires_in"):
params["expires_at"] = int(time.time()) + int(params["expires_in"])
super().__init__(params)

@@ -17,2 +25,5 @@

return None
# Only check expiration if expires_at is an integer
if not isinstance(expires_at, int):
return None
# small timedelta to consider token as expired before it actually expires

@@ -19,0 +30,0 @@ expiration_threshold = expires_at - leeway

@@ -11,2 +11,3 @@ """authlib.oidc.core.grants.code.

import logging
import warnings

@@ -24,3 +25,3 @@ from authlib.oauth2.rfc6749 import OAuth2Request

class OpenIDToken:
def get_jwt_config(self, grant): # pragma: no cover
def get_jwt_config(self, grant, client): # pragma: no cover
"""Get the JWT configuration for OpenIDCode extension. The JWT

@@ -34,6 +35,6 @@ configuration will be used to generate ``id_token``.

def get_jwt_config(self, grant):
def get_jwt_config(self, grant, client):
return {
"key": read_private_key_file(key_path),
"alg": "RS256",
"alg": client.id_token_signed_response_alg or "RS256",
"iss": "issuer-identity",

@@ -44,2 +45,3 @@ "exp": 3600,

:param grant: AuthorizationCodeGrant instance
:param client: OAuth2 client instance
:return: dict

@@ -85,3 +87,13 @@ """

config = self.get_jwt_config(grant)
try:
config = self.get_jwt_config(grant, request.client)
except TypeError:
warnings.warn(
"get_jwt_config(self, grant) is deprecated and will be removed in version 1.8. "
"Use get_jwt_config(self, grant, client) instead.",
DeprecationWarning,
stacklevel=2,
)
config = self.get_jwt_config(grant)
config["aud"] = self.get_audiences(request)

@@ -88,0 +100,0 @@

import logging
import warnings

@@ -39,3 +40,3 @@ from authlib.oauth2.rfc6749 import AccessDeniedError

def get_jwt_config(self):
def get_jwt_config(self, client):
"""Get the JWT configuration for OpenIDImplicitGrant. The JWT

@@ -45,6 +46,6 @@ configuration will be used to generate ``id_token``. Developers

def get_jwt_config(self):
def get_jwt_config(self, client):
return {
"key": read_private_key_file(key_path),
"alg": "RS256",
"alg": client.id_token_signed_response_alg or "RS256",
"iss": "issuer-identity",

@@ -54,2 +55,3 @@ "exp": 3600,

:param client: OAuth2 client instance
:return: dict

@@ -149,3 +151,13 @@ """

def process_implicit_token(self, token, code=None):
config = self.get_jwt_config()
try:
config = self.get_jwt_config(self.request.client)
except TypeError:
warnings.warn(
"get_jwt_config(self) is deprecated and will be removed in version 1.8. "
"Use get_jwt_config(self, client) instead.",
DeprecationWarning,
stacklevel=2,
)
config = self.get_jwt_config()
config["aud"] = self.get_audiences(self.request)

@@ -152,0 +164,0 @@ config["nonce"] = self.request.payload.data.get("nonce")

Metadata-Version: 2.4
Name: Authlib
Version: 1.6.5
Version: 1.6.6
Summary: The ultimate Python library in building OAuth and OpenID Connect servers and clients.

@@ -5,0 +5,0 @@ Author-email: Hsiaoming Yang <me@lepture.com>