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

Fix AttributeError and HTTP Configuration for Fedora Login Authentication #1725

Closed
wants to merge 3 commits into from

Conversation

NyuydineBill
Copy link
Contributor

Description:

Changes Made:

  1. Replaced the usage of the deprecated base64.encodestring with base64.encodebytes to resolve the AttributeError encountered during authentication with Fedora login in the Flask application.
  2. Updated the Flask application configuration to use HTTP instead of HTTPS to resolve server errors encountered during login.

Details:

Replacement of encodestring:

The AttributeError was raised due to the usage of the deprecated encodestring attribute of the base64 module. In Python 3, encodestring has been deprecated and replaced with encodebytes. This change ensures compatibility with Python 3 and resolves the error.

HTTP Configuration Update:

The Flask application was configured to run over HTTPS by default, causing server errors when logging in due to mismatched protocols. To address this issue, the SERVER_NAME configuration variable in the wsgi.py file was modified to use HTTP instead of HTTPS.

Steps Taken:

  1. Located the file causing the AttributeError (storage.py within the social_sqlalchemy package).
  2. Opened the storage.py file in a text editor.
  3. Replaced instances of base64.encodestring with base64.encodebytes.
  4. Modified the wsgi.py file to set the SERVER_NAME configuration variable to use HTTP (http://localhost:5000).
  5. Tested the changes locally to ensure successful authentication with Fedora login and resolved server errors during login.
  6. Created this pull request to contribute the fixes back to the original repository.

Additionally I have created a file named Auth_ERROR_README.md where you can see full steps to resolve this

…or resolving server errors during login

Added New file Auth_ERROR-README.md with the description on how to fix this error
@NyuydineBill NyuydineBill requested a review from a team as a code owner March 8, 2024 08:29
Copy link

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/e7a03a80d7394f14a3eb4a6598f18958

✔️ fi-tox-mypy SUCCESS in 6m 38s
✔️ fi-tox-lint SUCCESS in 6m 44s
fi-tox-format FAILURE in 4m 51s
✔️ fi-tox-python38 SUCCESS in 10m 34s
✔️ fi-tox-python39 SUCCESS in 8m 49s
✔️ fi-tox-python310 SUCCESS in 10m 46s
✔️ fi-tox-python311 SUCCESS in 10m 00s
✔️ fi-tox-docs SUCCESS in 6m 25s
✔️ fi-tox-bandit SUCCESS in 5m 57s
✔️ fi-tox-diff-cover SUCCESS in 11m 44s

…or resolving server errors during login

Added New file Auth_ERROR-README.md with the description on how to fix this error
Copy link
Contributor

@Zlopez Zlopez left a comment

Choose a reason for hiding this comment

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

Looking at the guide it would be better to fix the issue itself than adding a workaround documentation. I will look at the social_sqlalchemy issue and try to fix that.

Also the documentation is in https://github.com/fedora-infra/anitya/tree/master/docs, adding new README will be just confusing.

server_change.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This change shouldn't be done here, but better here, as we only want dev environment to run as HTTP not anything else.

### Solution
To resolve the AttributeError, replace `encodestring` with `encodebytes` in the affected file (`storage.py` within the `social_sqlalchemy` package). To resolve the server errors when logging in, change the Flask application configuration to run over HTTP instead of HTTPS.

### Steps to Resolve
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like the issue is with old social_sqlalchemy dependency. I will look into that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend to remove this file altogether and I need to fix the dev environment as I wasn't aware that there are issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I just removed them

Copy link

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/af862d59781e48d68aa6bbf4aec06431

✔️ fi-tox-mypy SUCCESS in 5m 44s
✔️ fi-tox-lint SUCCESS in 7m 47s
✔️ fi-tox-format SUCCESS in 4m 55s
✔️ fi-tox-python38 SUCCESS in 11m 21s
✔️ fi-tox-python39 SUCCESS in 11m 18s
✔️ fi-tox-python310 SUCCESS in 9m 23s
✔️ fi-tox-python311 SUCCESS in 9m 08s
✔️ fi-tox-docs SUCCESS in 6m 26s
✔️ fi-tox-bandit SUCCESS in 7m 17s
✔️ fi-tox-diff-cover SUCCESS in 9m 49s

@Zlopez
Copy link
Contributor

Zlopez commented Mar 8, 2024

I think we can close it as there are no files added, but you can write your solution to issue you created so it's documented.

@Zlopez Zlopez closed this Mar 8, 2024
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