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

Fixes #13749 - Handle Base64 and binary LDAP avatars #5630

Merged
merged 1 commit into from Jun 7, 2018

Conversation

dLobatog
Copy link
Member

Before this change, we would always try to Base64.decode absolutely any
avatar. This resulted in broken images, as sometimes the avatars are
automatically turned into binary by net/ldap. In such cases, we want to
save that directly, no decoding needed.

We also had a minor bug - when a user gets its LDAP avatar updated, the
old one could not be deleted. This results in broken log in. The bug
was quite minor, the variable where the file was supposed to be was
simply undefined.

@waldirio it'd be very helpful if you could test this one on your systems. Thanks!

@theforeman-bot
Copy link
Member

Issues: #13749

@@ -214,12 +214,21 @@ def avatar_path
end

def store_avatar(avatar)
avatar = avatar.to_utf8
avatar = avatar.instance_of?(Net::BER::BerIdentifiedString) ? avatar :

Choose a reason for hiding this comment

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

Style/MultilineTernaryOperator: Avoid multi-line ternary operators, use if or unless instead.

ares
ares previously requested changes May 31, 2018
Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

needs fixing the syntax error first :-)

@@ -214,12 +214,22 @@ def avatar_path
end

def store_avatar(avatar)
avatar = avatar.to_utf8
if !avatar.instance_of?(Net::BER::BerIdentifiedString)
Copy link
Member

Choose a reason for hiding this comment

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

this if/else is missing end, causing all Foreman tests failures :-)

@@ -214,12 +214,22 @@ def avatar_path
end

def store_avatar(avatar)
avatar = avatar.to_utf8
if !avatar.instance_of?(Net::BER::BerIdentifiedString)

Choose a reason for hiding this comment

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

Style/NegatedIf: Favor unless over if for negative conditions.

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

@ares Updated 👍 I wanted to quickly fix a hound warning but didn't run tests, should be fine now

@ares
Copy link
Member

ares commented Jun 4, 2018

[test upgrade]

@waldirio
Copy link

waldirio commented Jun 5, 2018

Hello folks, did the test, infos on the link below.

https://bugzilla.redhat.com/show_bug.cgi?id=1573243#c8

@dLobatog works fine but was necessary change the folder location one more change on the code.

Thank you all.

Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

@waldirio Thanks, you're totally right.

app/helpers/application_helper.rb
373:      image_tag("avatars/#{user.avatar_hash}.jpg", html_options)

image_tag looks into public/images so that should really be the path. I'll fix it asap. Thanks again!

Before this change, we would always try to Base64.decode absolutely any
avatar. This resulted in broken images, as sometimes the avatars are
automatically turned into binary by net/ldap. In such cases, we want to
save that directly, no decoding needed.

We also had a minor bug - when a user gets its LDAP avatar updated, the
old one could not be deleted. This results in *broken* log in. The bug
was quite minor, the variable where the file was supposed to be was
simply undefined.
Copy link
Member Author

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

Updated @waldirio @ares !

@dLobatog
Copy link
Member Author

dLobatog commented Jun 5, 2018

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

codes makes sense, but I don't have a ldap with binary avatars set up atm to test.

Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

I don't have LDAP with binary blobs either.

@waldirio
Copy link

waldirio commented Jun 6, 2018

Hello folks

-removed-

  • Service Account
    -removed- / -removed-

  • User
    -removed-/-removed-

Feel free to use this server

  • https://-removed-.usersys.redhat.com/

    admin/-removed-
    root/-removed-

Ps.: Just internal server and used for test, nothing related to production or personal use, just lab.

Ps.: Ldap, your account with your picture / avatar.

Edit (lzap): Removed IP address, hostname and passwords.

@waldirio
Copy link

waldirio commented Jun 6, 2018

Folks, one additional info

We can see the similar behaviour on Satellite 6.2, the point is, on 6.2 the avatar didn't show, on 6.3 we can see the long hash on the avatar place.

Best

@dLobatog
Copy link
Member Author

dLobatog commented Jun 7, 2018

@waldirio I was able to confirm with your box. 🥇

@tbrisker tbrisker dismissed ares’s stale review June 7, 2018 15:53

issues adressed.

@tbrisker
Copy link
Member

tbrisker commented Jun 7, 2018

Thanks @dLobatog @lzap @ares @waldirio !

@tbrisker tbrisker merged commit 87194fa into theforeman:develop Jun 7, 2018
@lzap
Copy link
Member

lzap commented Jun 8, 2018

@waldirio you want to remove the hostname, IP and credentials from here? :-)

@waldirio
Copy link

waldirio commented Jun 8, 2018

Hey @lzap

Yeap, feel free, just take a note if you need to future tests.

Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants