Skip to content

Commit

Permalink
Merge pull request #233 from TeskaLabs/fix/remove-expiration-from-log…
Browse files Browse the repository at this point in the history
…in-params

Expiration removed from login query params
  • Loading branch information
byewokko authored Jul 13, 2023
2 parents 64eab67 + c4adf5d commit 4adcb6a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

### Breaking changes
- Old Batman sessions are invalidated (#230, PLUM Sprint 230630)
- Expiration removed from login query params (#233, PLUM Sprint 230630)

### Fix
- Root session must be as long as its longest subsession (#228, PLUM Sprint 230630)
- Webauthn `user_name` can be either email address or phone number (#229, PLUM Sprint 230630)
- Batman token uses native ASAB Storage encryption (#230, PLUM Sprint 230630)
- Expiration removed from login query params (#233, PLUM Sprint 230630)

### Features
- Added alternative POST endpoint for Batman introspection (#230, PLUM Sprint 230630)
Expand Down
11 changes: 0 additions & 11 deletions seacatauth/authn/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ async def login_prologue(self, request, *, json_data):
ident = json_data.get("ident")

# Get arguments specified in login URL query
expiration = None
login_preferences = None
query_string = json_data.get("qs")
if query_string is None:
Expand All @@ -104,15 +103,6 @@ async def login_prologue(self, request, *, json_data):
raise asab.exceptions.ValidationError("Invalid request")
login_dict[k] = v[0]

# Get requested session expiration
# TODO: This option should be moved to client config or removed completely
expiration = query_dict.get("expiration")
if expiration is not None:
try:
expiration = float(expiration[0])
except Exception as e:
L.warning("Error when parsing expiration: {}".format(e))

# Get preferred login descriptor IDs
# TODO: This option should be moved to client config or removed completely
login_preferences = query_dict.get("ldid")
Expand Down Expand Up @@ -159,7 +149,6 @@ async def login_prologue(self, request, *, json_data):
client_public_key=key.get_op_key("encrypt"), # extract EC public key from JWT
login_descriptors=login_descriptors,
ident=ident,
requested_session_expiration=expiration,
)

key = jwcrypto.jwk.JWK.from_pyca(login_session.PublicKey)
Expand Down
6 changes: 0 additions & 6 deletions seacatauth/authn/login_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(
remaining_login_attempts,
expires_at,
ident,
requested_session_expiration=None,
public_key=None,
data=None
):
Expand All @@ -44,7 +43,6 @@ def __init__(

# Login descriptor that successfully authenticated the login session
self.AuthenticatedVia = None
self.RequestedSessionExpiration = requested_session_expiration


@classmethod
Expand All @@ -56,7 +54,6 @@ def build(
login_descriptors,
login_attempts,
timeout,
requested_session_expiration=None,
data=None
):
# Generate shared encryption key
Expand All @@ -83,7 +80,6 @@ def build(
remaining_login_attempts=login_attempts,
expires_at=expires_at,
public_key=server_login_key.public_key(),
requested_session_expiration=requested_session_expiration,
data=data,
)

Expand All @@ -104,7 +100,6 @@ def serialize(self) -> dict:
for descriptor in self.LoginDescriptors
],
"idt": self.Ident,
"rse": self.RequestedSessionExpiration,
"d": self.Data,
}
return db_object
Expand All @@ -124,7 +119,6 @@ def deserialize(cls, authn_svc, db_object: dict):
remaining_login_attempts=db_object["la"],
expires_at=db_object["exp"],
public_key=cryptography.hazmat.primitives.serialization.load_pem_public_key(db_object["pk"]),
requested_session_expiration=db_object["rse"],
data=db_object["d"],
)

Expand Down
3 changes: 0 additions & 3 deletions seacatauth/authn/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ async def create_login_session(
client_public_key,
ident,
login_descriptors=None,
requested_session_expiration=None,
data=None,
):
# Prepare the login session
Expand All @@ -151,7 +150,6 @@ async def create_login_session(
login_descriptors=login_descriptors,
login_attempts=self.LoginAttempts,
timeout=self.LoginSessionExpiration,
requested_session_expiration=requested_session_expiration,
data=data,
)

Expand Down Expand Up @@ -332,7 +330,6 @@ async def login(self, login_session, from_info: list = None):

session = await self.SessionService.create_session(
session_type="root",
expiration=login_session.RequestedSessionExpiration,
session_builders=session_builders,
)
L.log(
Expand Down
3 changes: 2 additions & 1 deletion seacatauth/openidconnect/handler/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ async def authorize(self, request, request_parameters):
# Check the presence of required parameters
self._validate_request_parameters(request_parameters)

# TODO: Remove this. These extra options should either be in scope or in client config.
login_parameters = {
k: v for k, v in request_parameters.items()
if k in frozenset(("ldid", "expiration"))
if k in frozenset(("ldid",))
}

# Authentication Code Flow
Expand Down

0 comments on commit 4adcb6a

Please sign in to comment.