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

Allow no notification address or type #197

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

pmeulen
Copy link
Member

@pmeulen pmeulen commented Aug 5, 2024

Normally a client sends the notificationAddress and notificationType parameters with each registration and authentication response as HTTP POST parameters. In some situations however a tiqr client can not get a notification address. Different clients respond (and have responded) differently to this situation. The notificationAddress and notificationType parameters may be absent, or both or only notificationAddress maybe set to the string "(null)" or "NULL". This leads to several issues that this PR addresses:

  • Currently there are user entries in the user storage table that have notificationAddress set to '(null)' or 'NULL'. Stepup-tiqr tries to send a push notification to these addresses, and that leads to an error. We change this behaviour so that NULL or (null) means no push address / type so no notification is send. We explicitly log this situation.

  • When a client omits a notificationAddress or notificationType this currently leads to an exception and the registration will fail. We change this behaviour so that this is accepted and allow the registration and authentication to continue.

pmeulen added 2 commits August 5, 2024 16:30
Don't try to send a push notifications when this happens and explicitly log when no push notification address is available
@pmeulen pmeulen requested a review from MKodde August 6, 2024 09:09
@pmeulen pmeulen self-assigned this Aug 6, 2024
// Filter bogus "null" and "(null)" entries that were put in the database by returning '' instead.
// There is no point in trying to send a notification to such addresses.
$notificationAddressLower = strtolower($notificationAddress);
if (($notificationAddressLower == 'null') || ($notificationAddressLower == '(null)')) {
Copy link
Member

Choose a reason for hiding this comment

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

First off, this is a very effective way to stop this value from being used as the notification address! One would hope the Tiqr server user storage would prevent this from happening.

Wouldn't it be better to let the source of the data guard the values being sent out? Its always a bit of a debate who is responsible for data integrity.

Finally. Have you actually seen a (null) string value? Or is this what you see in the database GUI when inspecting the field? I've never seen this happening before.

Copy link
Member Author

Choose a reason for hiding this comment

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

(null) is how objective-C (used in the iOS app) converts null/nil values to string, so we see this one a lot.

The expectation of the server is that the notificationAddress is an opaque string, so that is why it did/does not enforce anything. This happening is unintended behaviour by the apps, and it has been happening in the past. We've been fixing this, but that does not change what is in the database currently. Also we're not willing to force people to update the app over this (which would mean locking them out if they don't) as it is merely an annoyance, not a security bug.

Yes, solving this in the userStorage would have been an option too. But the userStorage being an optional class, I did not want to change its interface, a bit academic, true. I actually "like" to see the wrong values appear in the data base, because this tells us when there is an issue how many accounts are affected. That is why I put the guard on the way out, not the way in.

@pmeulen pmeulen merged commit 71fc23c into main Aug 8, 2024
6 checks passed
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