tosher/Mediawiker

Firefox Cookie login

Closed this issue · 8 comments

Hi,

trying to login to a private Wiki (mediawiki) with firefox cookie auth, but following error occurs.

Config:

{
	"site":
	{
		"xxx Wiki":
		{
			"authorization_type": "cookies",
			"host": "xxx.org",
			"is_ssl_cert_verify": true,
			"pagepath": "/",
			"path": "/",
			"cookies_browser": "firefox",
			"https": true,

		}
	},
	"site_active": "xxx Wiki",
	"debug": true,
}

Console Output:

'''Setup new connection to "xxx Wiki".'''
Connecting to "https://xxx.org" ..  done.
Login in with authorization type cookies (firefox)..  done, without authorization.
  >>> '''DEBUG''' Get connection from connection manager.
  >>> '''DEBUG''' Connection: <requests.sessions.Session object at 0x00000204BFC655C0>
Anonymous connection detected, forcing new connection.. 
Connecting to "https://xxx.org" ..  done.
Login in with authorization type cookies (firefox)..  done, without authorization.
  >>> '''DEBUG''' Get connection from connection manager.
  >>> '''DEBUG''' Connection: <requests.sessions.Session object at 0x00000204BFC5D8D0>
Page [[xxx]] was opened successfully from "xxx Wiki".
  >>> '''DEBUG''' Get connection from connection manager.
  >>> '''DEBUG''' Cached connection: True
Anonymous connection detected, forcing new connection.. 
Connecting to "https://xxx.org" ..  done.
Login in with authorization type cookies (firefox)..  done, without authorization.
  >>> '''DEBUG''' Get connection from connection manager.
  >>> '''DEBUG''' Connection: <requests.sessions.Session object at 0x00000204BF190470>

Also tried to specify the firefox cookie location, but same behaviour.

Any ideas on the issue?

Api page available at https://xxx.org/api.php and page xxx (https://xxx.org/xxx) opened successfully (in read mode), is it right?

Api page available at https://xxx.org/api.php and page xxx (https://xxx.org/xxx) opened successfully (in read mode), is it right?

Yep, .org/api.php in browser opens successfully the automated api help page and .org/page is opened successfully in read mode only.

I don't know if it helps, but the login in the wiki is done with SSO to another site which does not host a wiki itself. Firefox cache shows the cookie with login name and session id valid until end of firefox session.

The plugin tries to find cookies for wiki host.. if your wiki using another host (another host-cookies) for authorization it will fail :(
We can try to add a new option with auth-host, maybe it will help...

To try:

{sublime_text_folder}/Data/Packages/Mediawiker/mwcommands/mw_utils.py (win)

  • Backup original file :)
  • Make changes:

Line

            site['host'] = site_config['host']

replace with

            # site['host'] = site_config['host']
            if '/' in site_config['host']:
                host_auth, host = site_config['host'].split('/')
            else:
                host_auth = None
                host = site_config['host']
            site['host'] = host
            site['host_auth'] = host_auth

then:

        if site['cookies_browser'] == "firefox":
            return browser_cookie3.firefox(
                cookie_file=cookie_files[0] if cookie_files else None,
                domain_name=site['host'],

replace with:

        if site['cookies_browser'] == "firefox":
            return browser_cookie3.firefox(
                cookie_file=cookie_files[0] if cookie_files else None,
                # domain_name=site['host'],
                domain_name=site['host_auth'] if site['host_auth'] else site['host'],

After that, set host option as

"host": "{host_auth}.org/xxx.org"

To try:
[...]

I tried things as mentioned but without success, same error. In the mean time I did a quick and dirty Win-VM with chrome and the chrome cookie works out of the box without editing mw_uitls.py

If chrome works, it means the path to cookie file is a problem.. 98%