Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Successful login instantly returns login page #272

Closed
cmacrae opened this issue Feb 20, 2015 · 15 comments
Closed

Successful login instantly returns login page #272

cmacrae opened this issue Feb 20, 2015 · 15 comments
Labels

Comments

@cmacrae
Copy link

cmacrae commented Feb 20, 2015

First off: thank you for Uchiwa!

Right, now to the point: I'm running Uchiwa (and Sensu) in a SmartOS zone.
Everything works great, apart from the login functionality.

When using the user & pass key/value in config.json, a login page appears as expected, but - upon entering valid credentials - the user is instantly returned to the login page (you can see the interface load for a split second before you're back at the login page).

Here's my config.json:

{
    "sensu": [
        {
            "name": "dc_name",
            "host": "localhost",
            "ssl": false,
            "port": 4567,
            "user": "admin",
            "pass": "********",
            "timeout": 5000
        }
    ],
    "uchiwa": {
        "user": "admin",
        "pass": "********",
        "port": 3000,
        "stats": 10,
        "refresh": 10000
    }
}

Note: 'pass' values replaced with '****'

All browser caches have been cleared, along with trying visiting the site on a fresh device that's never visited the Uchiwa instance before - but the problem persists.

I've tried running the process in the foreground to see if anything is spat out to stdout/stderr, but nothing.

When entering incorrect credentials, there's a warning that appears in the web GUI (as expected), and the following is sent to stdout/stderr:
{"Date":"2015-02-20T09:27:27.980366658Z","Level":"info","Src":{"Func":"github.com/palourde/auth.func·004","Line":86},"Output":"Authentication failed: invalid user 'admin' or invalid password"}

Go version is go1.3.2 solaris/amd64
Node version is v0.10.36

I've span up a test instance over at https://sensu.cmacr.ae (sorry, self-signed cert :) ) where those willing to look into this can see this behaviour, using the following credentials:
Username: admin
Password: admin

Thanks in advance for any help on this! Please do let me know if there's any other information I can provide that would help the investigation.

Looking forward to contributing to the Sensu/Uchiwa community :)

@cmacrae
Copy link
Author

cmacrae commented Feb 20, 2015

adobrosynets_ on #sensu noted the following after a little investigation:

i see "no token present in request" in services.js:103, in
js console.log , https://sensu.cmacr.ae/get_config

Also:

I also see cookie variable 'uchiwa_auth' does
not show up correctly in browser debug window

@cmacrae
Copy link
Author

cmacrae commented Feb 20, 2015

Taking a look at Chrome's debugger, I can also see GET https://sensu.cmacr.ae/get_sensu 401 (Unauthorized) is returned when attempting logins.

Upon inspection, people may notice I'm running this Uchiwa instance behind nginx.
This same behaviour is still exhibited when going directly to the Uchiwa process - so, that rules out nginx :)

@jcmartins
Copy link

+1

@palourde
Copy link
Contributor

Hi @cmacrae

I assume you installed Uchiwa from the source. Could you try to delete the public/bower_components folder and run npm install --production again?

Thanks!

@palourde palourde added the Bug label Feb 20, 2015
@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

Hey @palourde :)

Doesn't seem to have solved the issue I'm afraid.
I made sure to disable all Sensu related services before doing so, tried a couple times just to make sure, even tried a reboot - but; no dice.

@palourde
Copy link
Contributor

Hi @cmacrae

Could you make sure that the line 12 of the file public/bower_components/uchiwa-web/js/factories.js correspond to this one https://github.com/sensu/uchiwa-web/blob/master/js/factories.js#L12 ?

Also, make sure you pulled the latest changes for the Go librairies, especially for the following one: cd $GOPATH/src/github.com/palourde/auth && git pull origin master

Thanks!

@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

@palourde

Hmm, seems line 12 of factories.js is token = auth.token || null; - any idea why this would differ?
I retrieved the source using go get, and I can confirm all sources are up to date with their master branches

@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

Figured it may also be useful to include the first block of factories.js:

'use strict';

var factoryModule = angular.module('uchiwa.factories', []);

factoryModule.factory('authInterceptor', function ($cookieStore, $q, $location, userService) {
  return {
    request: function (config) {
      config.headers = config.headers || {};
      var auth = $cookieStore.get('uchiwa_auth');
      var token = null;
      if (angular.isDefined(auth)) {
        token = auth.token || null;
      }
      if (token) {
        config.headers.Authorization = 'Bearer ' + token;
      }
      return config;
    },
    responseError: function (rejection) {
      if (rejection.status === 401 || rejection.status === 403) {
        // handle the case where the user is not authenticated
        if ($location.path() !== '/login') {
          userService.logout();
          $location.path('login');
        }
      }
      return $q.reject(rejection);
    }
  };
});

@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

Strange that my factories.js should differ though... the local Git tree is definitely up to date :(

[root@sensu /opt/uchiwa/go/src/github.com/sensu/uchiwa]# git remote -v
origin  https://github.com/sensu/uchiwa (fetch)
origin  https://github.com/sensu/uchiwa (push)

[root@sensu /opt/uchiwa/go/src/github.com/sensu/uchiwa]# git pull origin master
From https://github.com/sensu/uchiwa
 * branch            master     -> FETCH_HEAD
Already up-to-date.

[root@sensu /opt/uchiwa/go/src/github.com/sensu/uchiwa]# echo $?
0

@palourde
Copy link
Contributor

@cmacrae Could you try to run the following command in order to reinstall the bower component uchiwa-web: bower uninstall uchiwa-web && bower install uchiwa-web

@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

@palourde

Re-installation of uchiwa-web doesn't seem to work with Bower:

bower uninstall     uchiwa-web
bower uninstall     angular-bootstrap
bower uninstall     angular-cookies
bower uninstall     angular-route
bower uninstall     angular-sanitize
bower uninstall     angular-toastr
bower uninstall     async
bower uninstall     bootstrap-sass-official
bower uninstall     bootstrap
bower uninstall     fontawesome
bower uninstall     highlightjs
bower uninstall     moment
bower uninstall     toastr
bower uninstall     underscore
bower uninstall     angular
bower uninstall     jquery
bower uchiwa-web#*              cached git://github.com/sensu/uchiwa-web.git#0.5.0
bower uchiwa-web#*            validate 0.5.0 against git://github.com/sensu/uchiwa-web.git#*
bower angular#~1.2.26           cached git://github.com/angular/bower-angular.git#1.2.28
bower angular#~1.2.26         validate 1.2.28 against git://github.com/angular/bower-angular.git#~1.2.26
bower angular-bootstrap#0.11.0  cached git://github.com/angular-ui/bootstrap-bower.git#0.11.0
bower angular-bootstrap#0.11.0         validate 0.11.0 against git://github.com/angular-ui/bootstrap-bower.git#0.11.0
bower angular-cookies#~1.2.26            cached git://github.com/angular/bower-angular-cookies.git#1.2.28
bower angular-cookies#~1.2.26          validate 1.2.28 against git://github.com/angular/bower-angular-cookies.git#~1.2.26
bower angular-route#~1.2.26              cached git://github.com/angular/bower-angular-route.git#1.2.28
bower angular-route#~1.2.26            validate 1.2.28 against git://github.com/angular/bower-angular-route.git#~1.2.26
bower angular-sanitize#~1.2.26           cached git://github.com/angular/bower-angular-sanitize.git#1.2.28
bower angular-sanitize#~1.2.26         validate 1.2.28 against git://github.com/angular/bower-angular-sanitize.git#~1.2.26
bower angular-toastr#~0.3.0              cached git://github.com/Foxandxss/angular-toastr.git#0.3.0
bower angular-toastr#~0.3.0            validate 0.3.0 against git://github.com/Foxandxss/angular-toastr.git#~0.3.0
bower async#~0.9.0                       cached git://github.com/caolan/async.git#0.9.2
bower async#~0.9.0                     validate 0.9.2 against git://github.com/caolan/async.git#~0.9.0
bower bootstrap#3.1.1                    cached git://github.com/twbs/bootstrap.git#3.1.1
bower bootstrap#3.1.1                  validate 3.1.1 against git://github.com/twbs/bootstrap.git#3.1.1
bower bootstrap-sass-official#3.1.1      cached git://github.com/twbs/bootstrap-sass.git#3.1.1
bower bootstrap-sass-official#3.1.1    validate 3.1.1 against git://github.com/twbs/bootstrap-sass.git#3.1.1
bower fontawesome#4.1.0                  cached git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower fontawesome#4.1.0                validate 4.1.0 against git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower highlightjs#~8.3.0                 cached git://github.com/components/highlightjs.git#8.3.0
bower highlightjs#~8.3.0               validate 8.3.0 against git://github.com/components/highlightjs.git#~8.3.0
bower moment#~2.8.3                      cached git://github.com/moment/moment.git#2.8.4
bower moment#~2.8.3                    validate 2.8.4 against git://github.com/moment/moment.git#~2.8.3
bower toastr#~2.0.3                      cached git://github.com/johnpapa/toastr-bower.git#2.0.3
bower toastr#~2.0.3                    validate 2.0.3 against git://github.com/johnpapa/toastr-bower.git#~2.0.3
bower underscore#~1.6.0                  cached git://github.com/jashkenas/underscore.git#1.6.0
bower underscore#~1.6.0                validate 1.6.0 against git://github.com/jashkenas/underscore.git#~1.6.0
bower                                 ENOTFOUND Package uchiwa-web not found

The only way I'm able to reinstall uchiwa-web is by doing npm install --production again

(Thanks for the help so far btw! I'm currently writing an Ansible role for Sensu & Uchiwa on SmartOS, so will be nice to have this working)

@palourde
Copy link
Contributor

@cmacrae I'll release 0.5.1 today as soon I'm done with few bug fixes, including one for this issue.

I'll register the uchiwa-web bower package to the bower registry and also pin the uchiwa-web version in Uchiwa.

I'll let you know as soon it's ready!

@cmacrae
Copy link
Author

cmacrae commented Feb 21, 2015

@palourde
Ah, dude that's great! Thanks for all your work on this - looking forward to it :)

@palourde
Copy link
Contributor

0.5.1 packages are now available and uchiwa-web has been registered as a bower package.

Let me know if you still face any issue!

@cmacrae
Copy link
Author

cmacrae commented Feb 22, 2015

@palourde
It works! 👍
Awesome, thanks so much :D

timmow added a commit to alphagov/pp-puppet that referenced this issue Mar 5, 2015
This is the version used in production and staging, the module sets
ensure latest by default. There seems to be a bug in the latest version
affecting us on preview, which was upgraded

sensu/uchiwa#272
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants