Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change AuthenticationManager to class with lock #142

Merged

Conversation

FranzBusch
Copy link
Contributor

Motivation

Currently, the JWT authentication is using two actors to isolate the state. This leads to thread hops for every APNS request which we can avoid with using a Lock instead.

Modification

This PR contains a couple of modifications to the JWT authentication handling:

  • Refactor the two actors to a single class using a Lock
  • Drop the dependency on Foundation from the JWT handling.
  • Improve the logging
  • Add tests to verify the behaviour of the new JWT generation.

Result

We now have a faster and better tested JWT handling.

# Motivation
Currently, the JWT authentication is using two actors to isolate the state. This leads to thread hops for every APNS request which we can avoid with using a `Lock` instead.

# Modification
This PR contains a couple of modifications to the JWT authentication handling:
- Refactor the two actors to a single class using a `Lock`
- Drop the dependency on `Foundation` from the JWT handling.
- Improve the logging
- Add tests to verify the behaviour of the new JWT generation.

# Result
We now have a faster and better tested JWT handling.
Copy link
Member

@kylebrowning kylebrowning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really smart and a great use of lock.

I especially like the simplification of the process and the breakout of variables.

Thank you for doing this! Tests should be running.

@kylebrowning kylebrowning merged commit 35220e9 into swift-server-community:main Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants