taiga-back icon indicating copy to clipboard operation
taiga-back copied to clipboard

Upgrade authentication issues

Open msabae opened this issue 6 years ago • 24 comments

Here's my current environment: Python 3.5.2 Django 1.10.6

I followed the production document and have the following error: I can login normally, view my projects and browse around but I cannot edit any data.

In checking my console, I get the following error: {"_error_type": "taiga.base.exceptions.NotAuthenticated", "_error_message": "Authentication credentials were not provided."}

Here are my headers

Accept:application/json, text/plain, */*
Accept-Language:en
Authorization:Bearer eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjoxOH0:1dpkGV:3IKmEYSO0e5HIuir0qo84hgPaJw
Content-Type:application/json
Origin:http://myurl.com
Referer:http://myurl.com/project/myproject/issue/470
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
X-Session-Id:bb82ec1f0bd24e24addf6f14c4fa3b8a7d364fbe

To continue using Django admin, I had to add the following to my local.py:

from .common import *

INSTALLED_APPS += ["taiga_contrib_slack"]
MEDIA_URL = "http://myurl.com/media/"
STATIC_URL = "http://myurl.com/static/"
STATIC_ROOT = '/home/taiga/taiga-back/static/'
SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "myurl.com"

SECRET_KEY = "mysecret"

DEBUG = True

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,
        'OPTIONS': {
        'debug': True,
        'context_processors': [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                # list if you haven't customized them:
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "[email protected]"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'myemailpassword'

#Admin emails
ADMINS = (("myname", "[email protected]"))


#Celery
CELERY_ENABLED = True

#Events
EVENTS_PUSH_BACKEND = "taiga.events.backends.rabbitmq.EventsPushBackend"
EVENTS_PUSH_BACKEND_OPTIONS = {"url": "amqp://taiga:myeventspassword@localhost:5672/taiga"}

If I remove the 'django.contrib.auth.context_processors.auth', I get the following error when I run: python manage.py migrate --noinput ?: (admin.E402) 'django.contrib.auth.context_processors.auth' must be in TEMPLATES in order to use the admin application.

Your help is very much appreciated!

msabae avatar Sep 07 '17 00:09 msabae

What taiga-back version are you using?

bameda avatar Sep 07 '17 00:09 bameda

Latest stable version (pulled yesterday)

msabae avatar Sep 07 '17 10:09 msabae

So common.py for this version have:

TEMPLATES = [
    {
        "BACKEND": "django_jinja.backend.Jinja2",
        "DIRS": [
            os.path.join(BASE_DIR, "templates"),
        ],
        "APP_DIRS": True,
        "OPTIONS": {
            'context_processors': [
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.request",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
            ],
            "match_extension": ".jinja",
        }
    },
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            os.path.join(BASE_DIR, "templates"),
        ],
        "APP_DIRS": True,
        "OPTIONS": {
            'context_processors': [
                "django.contrib.auth.context_processors.auth",
                "django.template.context_processors.request",
                "django.template.context_processors.i18n",
                "django.template.context_processors.media",
                "django.template.context_processors.static",
                "django.template.context_processors.tz",
                "django.contrib.messages.context_processors.messages",
            ],
        }
    },

So your overwrite is wrong. You are removing jinja backend and excluding some context processers (django.template.context_processors.request) in the django backend.

Remove TEMPLATES in local.py and review if you have applied some changes in common.py that could be the problem.

bameda avatar Sep 07 '17 11:09 bameda

Thanks for the prompt reply.

I made sure common.py was updated and tried again. This time, I am not getting any errors when I run python manage.py migrate --noinput

I logged out and logged in again, ran all the upgrade commands but still getting the same error.

Failed to load resource: net::ERR_EMPTY_RESPONSE: /api/v1/issues/914

When I open the URL I get: {"_error_type": "taiga.base.exceptions.NotAuthenticated", "_error_message": "Authentication credentials were not provided."}

Thanks again!

msabae avatar Sep 07 '17 14:09 msabae

Mmmmm, try in an "incognito mode" window or remove the browser cache. Maybe it could be a problem with the network infrastructure that remove the auth header from the request. Are you behind a proxy, firewall or something similar? Could you chek if the request arrive to the server with all the headers?

bameda avatar Sep 07 '17 14:09 bameda

Tried in Incognito and a different browser.

Headers:

Request Headers

Provisional headers are shown
Accept:application/json, text/plain, */*
Accept-Language:en
Authorization:Bearer eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjoxOH0:1dpxut:l-1oRWTL2YV_163_MnHd4iPdIts
Content-Type:application/json
Origin:http://me.eseed.net
Referer:http://me.eseed.net/project/sonder-ios/issue/470
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
X-Session-Id:96e8f90e0fbdb410352fc9fa2ed72fc2ec06a83b

Still getting the same message: {"_error_type": "taiga.base.exceptions.NotAuthenticated", "_error_message": "Authentication credentials were not provided."}

Any other ideas?

msabae avatar Sep 07 '17 14:09 msabae

You are watching the browser request headers in the browser console, but you need to watch if the headers arribe to the server.

You could regenerate the user password and try again

bameda avatar Sep 07 '17 14:09 bameda

I changed the user password and tried to login again with incognito, still nothing.

I added a new user to the project and tried to change any data, same error.

Are there any logs or information that can help us debug this?

Thank you!

msabae avatar Sep 07 '17 15:09 msabae

maybe playing with the nginx settings to display the headers in the log file. Or debugging the code (https://github.com/taigaio/taiga-back/blob/master/taiga/auth/backends.py)

bameda avatar Sep 07 '17 15:09 bameda

I'm not very familiar with Django or Python. Any other advice that can help me resolve this?

Thanks again, I really appreciate your prompt help and advice

msabae avatar Sep 07 '17 15:09 msabae

I can't think of anything else, I created many crazy situations in Taiga, mixing different versions and things like that, but I had never faced this error. I am so sorry

bameda avatar Sep 07 '17 15:09 bameda

It gets crazier!

I deleted the server. Launched a new instance, re-followed all the production environment steps to the letter (without events), dumped and executed the database, copied the media folder.

My password didn't work anymore, I reset my password, gained access and tried multiple actions. It all worked fine.

I slept, woke up and now getting the same error!

Does this mean there's something wrong with my database? There's too much data for me to start from scratch. Any help out there?

msabae avatar Sep 08 '17 09:09 msabae

That's just weird!

@bameda Let me know if I missed anything below.

If I were in your shoes, I'd try the following trick to start a Taiga instance from scratch. (I must say: I don't take any sort of responsibility for the following actions. It's just an idea.)

First rename your current (production?) database to something else to preserve your data, and then setup a completely new Taiga instance. By this we can find out if it's a either a Taiga instance issue or a broken database issue.

To get started, issue the following commands: sudo su postgres cd ~ pg_dump taiga > taiga.sql

Move the taiga.sql file to a save location.

psql -c 'ALTER DATABASE taiga RENAME TO taiga_backup;'

By this, we have your Taiga database renamed, and the taiga name is free again.

If you have attachments or any sort of media uploaded; create a backup of taiga-back/media and taiga-back/static folders. Move them to a safe location.

Then remove everything related to Taiga (backend, frontend, taiga-events, circus config, remove the virtualenv ( rm -R /home/taiga/.virtualenvs/taiga/ ), really everything (refer to the documentation from bottom to top). You don't need to remove any packages, only Taiga and related config files.

Once you're done, follow the instructions set in the production documentation, and see if you can fire up a clean Taiga environment. If you succeed, and it works after numerous system restarts, browser changes, etc, let me know. If you fail, the problem is deeper than we expected.

theriverman avatar Sep 08 '17 13:09 theriverman

@theriverman I think he has done something similar to what you describe.

It smells like the problem here is that the browser sends the information correctly but the network (a proxy, firewall ...) is deleting some headers and they do not reach the taiga-back application.

Can you try with an empty database?, So make a db backup of your current data and run

cd taiga-back
workon taiga
./regenerate.sh

bameda avatar Sep 08 '17 14:09 bameda

And the craziness continues...

@bameda I tried the ./regenerate command, it gave me: FATAL: database "taiga" does not exist

So I created the database, ran the same command. Still nothing.

So I ran the following commands:

sudo -u postgres createdb taiga -O taiga
python manage.py migrate --noinput
python manage.py loaddata initial_user
python manage.py loaddata initial_project_templates
python manage.py compilemessages
python manage.py collectstatic --noinput
python manage.py sample_data

Everything loaded using admin (123123). I then logged in and edited something. It crashed! I got this:

/api/v1/userstories/1 Failed to load resource: net::ERR_EMPTY_RESPONSE
angular.js:11756 PUT http://mydomain.com/api/v1/user-storage/joyride 404 (Not Found)
angular.js:11756 GET http://mydomain.com/api/v1/user-storage/2ff7381dbe72b4eb601e64c9f18b86b3902a72e5 404 (Not Found)
angular.js:11756 GET http://mydomain.com/api/v1/user-storage/319e7926b0f4d11540dbd1ddfa417add4c54d4b4 404 (Not Found)
angular.js:11756 PUT http://mydomain.com/api/v1/user-storage/joyride 404 (Not Found)
angular.js:11756 PATCH http://mydomain.com/api/v1/userstories/2 net::ERR_EMPTY_RESPONSE

All URLs give me {"_error_message": "No StorageEntry matches the given query."}

Except /api/v1/userstories/2 gives me an actual response but says ERR_EMPTY_RESPONSE in the console. {"assigned_to_extra_info": {"id": 10, "full_name_display": "Enrique Crespo", "username": "user4", "is_active": true, "photo": null, "gravatar_id": "f31e0063c7cd6da19b6467bc48d2b14b", "big_photo": null}, "milestone": 1, "status_extra_info": {"name": "Ready", "is_closed": false, "color": "#ff8a84"}, "owner_extra_info": {"id": 9, "full_name_display": "Catalina Fernandez", "username": "user3", "is_active": true, "photo": null, "gravatar_id": "9971a763f5dfc5cbd1ce1d2865b4fcfa", "big_photo": null}, "sprint_order": 1504909608674, "kanban_order": 1504909608674, "epics": [{"id": 2, "subject": "get_actions() does not check for 'delete_selected' in actions", "ref": 107, "project": {"id": 1, "name": "Project Example 0", "slug": "project-0"}, "color": "#d3d7cf"}, {"id": 3, "subject": "Lighttpd support", "ref": 108, "project": {"id": 1, "name": "Project Example 0", "slug": "project-0"}, "color": "#75507b"}], "attachments": [], "owner": 9, "milestone_name": "Sprint 2017-7-15", "external_reference": null, "epic_order": null, "comment": "", "project": 1, "watchers": [], "team_requirement": false, "total_points": 83.0, "tags": [["ipsa", null], ["delectus", null], ["explicabo", "#2892cb"]], "created_date": "2017-09-08T22:26:48.674Z", "assigned_to": 10, "total_voters": 0, "version": 1, "description_html": "<p>Expedita corporis rerum suscipit quo eaque laboriosam ipsam illo, asperiores minus facere hic rem, placeat voluptas amet sunt neque officia maiores dolor tempora omnis laudantium, tempora ab debitis ratione harum commodi consequuntur fuga ad numquam, ullam facilis fugit voluptatem repellat officia obcaecati quia ducimus.</p>", "client_requirement": false, "subject": "get_actions() does not check for 'delete_selected' in actions", "id": 2, "origin_issue": null, "tasks": [], "milestone_slug": "sprint-2017-7-15", "blocked_note_html": "", "is_watcher": false, "is_blocked": false, "is_voter": false, "backlog_order": 1504909608674, "modified_date": "2017-09-08T22:26:48.923Z", "status": 2, "is_closed": false, "description": "Expedita corporis rerum suscipit quo eaque laboriosam ipsam illo, asperiores minus facere hic rem, placeat voluptas amet sunt neque officia maiores dolor tempora omnis laudantium, tempora ab debitis ratione harum commodi consequuntur fuga ad numquam, ullam facilis fugit voluptatem repellat officia obcaecati quia ducimus.", "blocked_note": "", "ref": 3, "neighbors": {"next": {"id": 3, "subject": "Feature/improved image admin", "ref": 9}, "previous": {"id": 1, "subject": "Lighttpd x-sendfile support", "ref": 1}}, "project_extra_info": {"name": "Project Example 0", "logo_small_url": null, "id": 1, "slug": "project-0"}, "total_comments": 1, "generated_from_issue": null, "finish_date": null, "total_watchers": 0, "points": {"2": 12, "1": 11, "3": 10, "4": 9}, "tribe_gig": null}

I'm going crazy here :(

msabae avatar Sep 08 '17 22:09 msabae

This messages are not errors, is because your user has not saved anything in his store.

angular.js:11756 PUT http://mydomain.com/api/v1/user-storage/joyride 404 (Not Found)
angular.js:11756 GET http://mydomain.com/api/v1/user-storage/2ff7381dbe72b4eb601e64c9f18b86b3902a72e5 404 (Not Found)
angular.js:11756 GET http://mydomain.com/api/v1/user-storage/319e7926b0f4d11540dbd1ddfa417add4c54d4b4 404 (Not Found)
angular.js:11756 PUT http://mydomain.com/api/v1/user-storage/joyride 404 (Not Found)

The problem is with this one:

angular.js:11756 PATCH http://mydomain.com/api/v1/userstories/2 net::ERR_EMPTY_RESPONSE

There is something between your browser and the taiga-back server who is malforming the requests and/or the responses.

Is there any proxy?, is there any firewall? have you some special configuration in you nginx, forexample something about the request o response size, or headers?

bameda avatar Sep 09 '17 00:09 bameda

I'm trying to execute python manage.py migrate for the first time after I passed the tutorial - Create a blank Django project. On the last step witch is: "Run Migration & Createsuperuser" I get some error in PowerShell.

Here it is: PS C:\Users\uvft\src> python manage.py migrate Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "C:\Program Files\Python36\lib\site-packages\django\core\management_init.py", line 364, in execute_from_comma nd_line utility.execute() File "C:\Program Files\Python36\lib\site-packages\django\core\management_init.py", line 308, in execute settings.INSTALLED_APPS File "C:\Program Files\Python36\lib\site-packages\django\conf_init_.py", line 56, in getattr self.setup(name) File "C:\Program Files\Python36\lib\site-packages\django\conf_init.py", line 41, in setup self.wrapped = Settings(settings_module) File "C:\Program Files\Python36\lib\site-packages\django\conf_init.py", line 110, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Program Files\Python36\lib\importlib_init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in load_unlocked File "", line 674, in exec_module File "", line 781, in get_code File "", line 741, in source_to_code File "", line 219, in call_with_frames_removed ValueError: source code string cannot contain null bytes

If someone can help me i would be grateful.

ignac328 avatar Oct 09 '17 17:10 ignac328

I don't use windows but it seems there are a null chars in your files... maybe in settings.

bameda avatar Oct 10 '17 08:10 bameda

What encoding are you using? Try to change to utf8. If you have to edit some file use an editor in utf8 too

bameda avatar Oct 10 '17 08:10 bameda

I use Save with Encoding option in Sublime Text and saved all files that are mentioned in the error as UTF-8. I still get the same error.

ignac328 avatar Oct 10 '17 11:10 ignac328

Maybe you have to set utf8 in PowerShell?

bameda avatar Oct 10 '17 12:10 bameda

I did it, active code page 65001. You can check that is UTF-8 here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx.

But I still get the same error and the migration or creation of a super user still not working.

ignac328 avatar Oct 10 '17 13:10 ignac328

I am so sorry but thge Taiga team doesn't work with wondows OS, according to our searches it seems a problem with encoding and null characters in some files. We try to help you with everything related to Taiga but windows is an unknown territory for us.

bameda avatar Oct 10 '17 23:10 bameda

I'm getting the 404 error while clicking the 'Issues' tab in a particular project in taiga. I can see the below error when I check the debugging in chrome.

No StorageEntry matches the given query

sibin-aeione avatar Oct 29 '21 04:10 sibin-aeione