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

Unable to login as admin on docker #1197

Closed
mekarpeles opened this issue Sep 27, 2018 · 22 comments
Closed

Unable to login as admin on docker #1197

mekarpeles opened this issue Sep 27, 2018 · 22 comments
Assignees
Labels
Affects: Admin/Maintenance Issues relating to support scripts, bots, cron jobs and admin web pages. [managed] Module: Docker Issues related to the configuration or use of Docker. [managed] Theme: Development Issues related to the developer experience and the dev environment. [managed] Theme: Provisioning

Comments

@mekarpeles
Copy link
Member

mekarpeles commented Sep 27, 2018

Multiple users have reported problems logging in as the dev admin user openlibrary and instead become logged in as openlibrary7774 or some other random number appended.

It looks like the cause is getting the admin123 password (an infogami default) incorrect the first time locks subsequent logins to the same non-privileged user openlibrary{random-number}

Clearing browser cookies and logging in again with the correct password works around this issue.

Not sure why the login uses the stored user in the cookie instead of what was entered by the user logging in -- this seems like a bug and should be investigated / fixed.

ACTION: For local dev login, stop old saved cookies from overriding the currently entered username the dev is trying to login with.

@mekarpeles mekarpeles added Affects: Admin/Maintenance Issues relating to support scripts, bots, cron jobs and admin web pages. [managed] dev-instance Theme: Provisioning Module: Docker Issues related to the configuration or use of Docker. [managed] labels Sep 27, 2018
@mekarpeles mekarpeles self-assigned this Sep 27, 2018
@hornc
Copy link
Collaborator

hornc commented Sep 27, 2018

I can login to the docker env as [email protected], pw: admin123 which is the test user

@mekarpeles
Copy link
Member Author

Can you access any of the admin routes?

@hornc
Copy link
Collaborator

hornc commented Sep 27, 2018

Turns out no, I can't, I get an error:
/openlibrary/openlibrary/templates/admin/index.html: error in processing template: AttributeError: 'reading_log' (falling back to default template)

I obviously haven't used the admin endpoint for a while, but believed (and still do) that the user's admin access is ok because I was importing and editing with admin privs.

@hornc
Copy link
Collaborator

hornc commented Sep 27, 2018

Error coming from here: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/admin/index.html#L172

/openlibrary/openlibrary/templates/admin/index.html in __template__
172.    <td class="amount">$commify(counts.reading_log['total_books_logged']['week']['count'])</td> 

@hornc
Copy link
Collaborator

hornc commented Sep 27, 2018

@mekarpeles .... and unfortunately I see the same thing in production when going to https://openlibrary.org/admin?debug=true

Is this the same issue as reported, or something else?

@hornc
Copy link
Collaborator

hornc commented Sep 28, 2018

re. the original question, I can access pages off /admin, eg http://localhost:8080/admin/people it's only the main admin page that gives the error.

@mekarpeles
Copy link
Member Author

mekarpeles commented Sep 28, 2018

/admin fixed on openlibrary.org (but is separate issue). It moved to /stats

There are other admin endpoints e.g. /admin/people which don't work for me when I login via docker or vagrant

@hornc
Copy link
Collaborator

hornc commented Oct 3, 2018

@mekarpeles I have tried the docker instructions from a fresh checkout of this repo and clean docker builds a+ volumes, and can log in as [email protected] and access the admin pages.
docker-compose up

@tfmorris
Copy link
Contributor

Now that login is fixed in general, it appears to me that this is no longer an issue. admin/people, in particular, works.

I do see errors for waiting lists and imports, but I think they're unrelated:

/openlibrary/openlibrary/templates/admin/waitinglists.html: error in processing template: ProgrammingError: relation "waitingloan" does not exist LINE 1: SELECT * FROM waitingloan WHERE status='available' ORDER BY ... ^ (falling back to default template)

@mekarpeles can this be closed?

@jdlrobson jdlrobson changed the title Unable to login as admin on vagrant + docker Unable to login as admin on docker Dec 21, 2018
@jdlrobson
Copy link
Collaborator

@tfmorris I'm still hitting this issue. I can't login as an admin. Every time I log in I end up as the user openlibrary7774

I for some reason have the user "openlibrary7774" locally. @hornc pointed out this could be a file permission issue.

@jdlrobson jdlrobson removed the vagrant label Dec 21, 2018
@tfmorris
Copy link
Contributor

I am able to successfully log in as an admin and see the following

  • admin - redirects to stats
  • people - renders
  • loans - renders
  • waitinglists - relation "waitingloan" does not exist LINE 1: SELECT * FROM waitingloan WHERE status='available' ORDER BY ... ^
    Python | /usr/local/lib/python2.7/dist-packages/DBUtils/SteadyDB.py in tough_method, line 604
  • block - renders
  • spamwords - renders
  • solr - renders
  • imports - relation "import_item" does not exist LINE 1: SELECT count(*) as count FROM import_item WHERE status='pend... ^
    Python | /usr/local/lib/python2.7/dist-packages/DBUtils/SteadyDB.py in tough_method, line 604
  • graphs - broken images
  • inspect store - renders
  • inspect memcache - renders

In summary it mostly works except for two errors which look like they could be because of missing data.

@mekarpeles @hornc Are you able to log in as admin now?

@jdlrobson
Copy link
Collaborator

For some reason when i login as any email address i end up assigned the username openlibrary1083.

When i try to register a new account i get email already registered...

@jdlrobson
Copy link
Collaborator

Is there a way i can delete all users in database to see if user creation is associated with this problem?

@mekarpeles
Copy link
Member Author

I'm hitting the same issue as @jdlrobson and we're hearing corroboration from @rohitjain00 who is also hitting this issue

@shreyansh23
Copy link
Contributor

@mekarpeles

I'm hitting the same issue as @jdlrobson and we're hearing corroboration from @rohitjain00 who is also hitting this issue

Yes, the issue is still there.

@mekarpeles
Copy link
Member Author

The admin user is defined within infogami repo in infogami/utils/delegate.py within admin_login and the admin_password is specified within openlibrary/config/openlibrary.yml within this repo.

The hypothesis is, use attempts to login with an email. The email and password don't match. The user openlibrary is deemed to already exist. Numbers are added onto the username. The username is created and the user is able to login but no longer as the admin user.

@mekarpeles mekarpeles assigned hornc and unassigned mekarpeles Apr 1, 2019
@mekarpeles
Copy link
Member Author

@hornc can you please update this task w/ the cache clearing fix?

@hornc
Copy link
Collaborator

hornc commented Apr 4, 2019

Here are the steps to clear cookies and re-enable admin login if you get stuck with a non-admin user:

  1. docker-compose down
  2. completely clear all localhost / 0.0.0.0 / 127.0.0.1 cookies from your browser
  3. docker-compose up
  4. then login with [email protected] pw: admin123 (It's possible there are acceptible variations on those credentials, but those should definitely work)

@tabshaikh
Copy link
Collaborator

#1197 (comment) @charles should we add this in the FAQ too

@hornc
Copy link
Collaborator

hornc commented Apr 5, 2019

@tabshaikh Good idea, but I think there is a bug that needs to be fixed first -- I have added a description to clarify the action I think needs to be taken to make the fix. Hopefully that will make the workaround unnecessary, but it needs some investigation and testing.

@mekarpeles
Copy link
Member Author

mekarpeles commented Apr 15, 2019

Closing this issue as has work-around. Updated the #2049 guide to reflect. We should probably open a new issue for solving the root of the problem (which requires better documentation) --

Fix login on dev instance to fail if incorrect admin credentials
If user on dev enters wrong admin email + password and spoofs login, unable to login as admin. The flow should be fixed

@brad2014 brad2014 added the Theme: Development Issues related to the developer experience and the dev environment. [managed] label May 14, 2019
@cdrini
Copy link
Collaborator

cdrini commented May 10, 2021

See also: #2050 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Affects: Admin/Maintenance Issues relating to support scripts, bots, cron jobs and admin web pages. [managed] Module: Docker Issues related to the configuration or use of Docker. [managed] Theme: Development Issues related to the developer experience and the dev environment. [managed] Theme: Provisioning
Projects
None yet
Development

No branches or pull requests

8 participants