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

Login error handling #124

Merged
merged 10 commits into from
Sep 8, 2024
Merged

Login error handling #124

merged 10 commits into from
Sep 8, 2024

Conversation

RA341
Copy link
Contributor

@RA341 RA341 commented Aug 29, 2024

Changes

Added support for autofill so that password managers can autofill credentials.

Ui changes

Default error handling UI.

default

Specific error messages for certain HTTP codes. If a response does not match a specific code, it defaults to the normal UI.

err

Added a check for empty inputs.

missing

Bug fix

There was also a bug in the auth logic

The if condition adds a port regardless of the protocol, which will cause a tls mismatch error if we put https address and the error handler adds the port.

relevant line

if (user.serverAdress!.split(":").last != "8096" &&
          user.serverAdress!.split(":").length == 2 

adds a HTTP check

if (user.serverAdress!.split(":").last != "8096" &&
          user.serverAdress!.split(":").length == 2 &&
          user.serverAdress!.split(":").first == 'http')

RA341 added 4 commits August 27, 2024 15:54
without this check, https address get added the port number which causes a tls mismatch.
switch (resp!.statusCode) {
case 400:
message =
'Something went wrong while making the request, this is probably a issue within Jellyflix, please open a github issue';
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need to reflect more standard representations of the code status. 401 is fine because this is a totally standard way of using it in jellyland, but the other two are a bit misleading. just go with "400 - Bad Request" or "403 - Forbidden"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind leaving them out, but here's my reasoning

400 - can only happen if the client library (tentacle) messes up a request or the server doesn't recognize the path for whatever reason either way its a bug within the app

403 - I guess is debatable but this only occurs if the server has banned your device IP or ratelimit I guess either way still relevant message.

My assumptions could be wrong so feel free to correct me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

imho it depends where in the flow we are making this determination. if we have already validated that we are talking to a jellyfin server and not something else in error, I think this 400 is ok. the 403 is a problem though because lots of different reverse proxy stuff could cause this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

tbh i have problems with the 400 too because of the potential issues with proxies. if there is a 400 or 403, it would be really nice to give the user as much info about it as possible instead of generalized lines. what do you think about using the response content itself in these cases?
@jdk-21 do you have an opinion on this one?

Copy link
Contributor Author

@RA341 RA341 Sep 2, 2024

Choose a reason for hiding this comment

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

ah i hadn't considered proxies, we could validate that we are talking to jellyfin first, based on this auth logic, if we get 400ed before that we show a normal exception for the proxy

Copy link
Collaborator

Choose a reason for hiding this comment

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

truth be told I don't see the wisdom in this function at all. this is a bit backwards in general because 1) you are covering over information about the real error that might be useful to the user or troubleshooter and then 2) you funnel these people into the support channels with less info than they might have had. this has negative impacts both on the UX and the support burden.
why isn't it better to unconditionally use Text(e.toString())

Copy link
Contributor Author

@RA341 RA341 Sep 2, 2024

Choose a reason for hiding this comment

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

To be clear, the function does not hide the HTTP error, it adds this message on top of the HTTP response (see image in the PR)

e.tostring will use dios inbuilt error response, which is a long (relatively)useless string you can see here, which is the reason why I added the messages

sev

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, well I take it back, I see the wisdom in that. how do you feel about the ux/support burden element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we can workshop the messages, and add like a FAQ section, I feel like it shouldn't be too bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the final message that gets displayed, let me know if you want additional info included

return '$message\n\n'
            'Http Code: ${resp.statusCode ?? 'Unknown'}\n\n'
            'Http Response: ${resp.statusMessage ?? 'Unknown'}\n\n'
        .trim();

@@ -60,7 +61,8 @@ class AuthService {
user.serverAdress!, user.name!, user.password!);
} catch (e) {
if (user.serverAdress!.split(":").last != "8096" &&
user.serverAdress!.split(":").length == 2) {
user.serverAdress!.split(":").length == 2 &&
Copy link
Collaborator

@sevenrats sevenrats Sep 1, 2024

Choose a reason for hiding this comment

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

this will not work. what if my server is at http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]
its true that the previous code was broken in this way as well, but not taking this opportunity to fix it would be silly. are you completely against using the regex I linked you? its really one of very few correct ways of approaching this issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sevenrats
Copy link
Collaborator

if you were open to fixing this while you were mucking about in this view that would be very helpful:
#63

@RA341
Copy link
Contributor Author

RA341 commented Sep 1, 2024

if you were open to fixing this while you were mucking about in this view that woul

if you were open to fixing this while you were mucking about in this view that would be very helpful: #63

I got it

#63 is implemented

@sevenrats
Copy link
Collaborator

looks great works great.
sorry this didn't occur to me earlier, but, jellyfin actually supports empty passwords.
for example this branch now prevents jellyflix from accessing the demo server at https://demo.jellyfin.org/stable
image

@RA341
Copy link
Contributor Author

RA341 commented Sep 2, 2024

removed the password check

@sevenrats
Copy link
Collaborator

@jdk-21 I'm plus one on this when you are ready to review.

Copy link
Collaborator

@sevenrats sevenrats left a comment

Choose a reason for hiding this comment

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

looks great, works great, responds properly to my modest fuzzing attempts.

@RA341
Copy link
Contributor Author

RA341 commented Sep 4, 2024

adding this one last change, to show URLs tried

image

Copy link
Collaborator

@jdk-21 jdk-21 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. LGTM
And @sevenrats for the review

@jdk-21 jdk-21 merged commit 2644984 into jellyflix-app:main Sep 8, 2024
1 check failed
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.

3 participants