smartdevicelink / sdl_server

The SmartDeviceLink (SDL) server handles authentication, data collection, and basic configurations for SDL connected vehicles.
BSD 3-Clause "New" or "Revised" License
20 stars 23 forks source link

Initial install permission issue. #6

Closed ssmereka closed 8 years ago

ssmereka commented 9 years ago

After the database is initialized for the first time users cannot log in. This is because of the data being cached is not updated.

Workaround for now: Restart server after database is initialized via the install flag (-i)

CallousOdesa commented 9 years ago

Hi, Scott,

I started server by "fox start -i -l" or "fox start -l" and allways error appears when trying to add user or add app or add car in client.

[ 403 ] You do not have permission to perform that action. [ 500 ] Error: You do not have permission to perform that action. at createAndSendError (/home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Server/send.js:128:13) at /home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Authentication/authorization.js:323:14 at /home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Authentication/authorization.js:131:12 at allow (/home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Authentication/accessToken.js:112:12) at checkRolePreconditions (/home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Authentication/authorization.js:80:20) at /home/amelnik/Downloads/SDLServer/server/node_modules/foxjs/libs/Authentication/authorization.js:292:5 at callbacks (/home/amelnik/Downloads/SDLServer/server/node_modules/express/lib/router/index.js:164:37) at param (/home/amelnik/Downloads/SDLServer/server/node_modules/express/lib/router/index.js:138:11) at param (/home/amelnik/Downloads/SDLServer/server/node_modules/express/lib/router/index.js:135:11) at pass (/home/amelnik/Downloads/SDLServer/server/node_modules/express/lib/router/index.js:145:5)

Kind regards, Andriy

ssmereka commented 9 years ago

It seems like the user you are logged in as does not have the correct user role, or the server does not have the user roles installed. My best guess based on your last issues is that your initial install failed. The easiest way to fix this is to drop your current database and then reinstall it.

mongo
use sdl_server
db.dropDatabase()
exit

Just a little bit of info so you understand what the "-i" flag does. It is an install flag which will trigger the server to create folders, load data into the database, and other initialization tasks. The install will only ever run once until you run uninstall or drop your database, so using the install flag to start the server more than once is ok, It will not mess anything up. However to actually send the install flag you have to do so like this:

  fox start -l -- -i

Notice that the '--' is used to separate where parameters are sent. Everything before the '--' is a parameter for fox and everything after is for the sdl server.

CallousOdesa commented 9 years ago

Hi, Scott,

I had used yours instructions and successfuly droped the database:

MongoDB shell version: 2.6.8 connecting to: test Server has startup warnings: 2015-03-12T12:37:08.759+0200 [initandlisten] 2015-03-12T12:37:08.759+0200 [initandlisten] * NOTE: This is a 32 bit MongoDB binary. 2015-03-12T12:37:08.759+0200 [initandlisten] * 32 bit builds are limited to less than 2GB of data (or less with --journal). 2015-03-12T12:37:08.759+0200 [initandlisten] * Note that journaling defaults to off for 32 bit and is currently off. 2015-03-12T12:37:08.759+0200 [initandlisten] * See http://dochub.mongodb.org/core/32bit 2015-03-12T12:37:08.759+0200 [initandlisten]

use sdl_server switched to db sdl_server db.dropDatabase() { "dropped" : "sdl_server", "ok" : 1 } exit bye

And after that started server: fox start -l -- -i [ OK ] Connected to the database. [ OK ] Listening on port 3000 in local mode with database sdl_local. [ INFO ] Created directory /home/amelnik/rep/MyServerName/client/assets/img/uploads/ Requesting data from http://140.147.249.7/standards/iso639-2/php/English_list.php Writing to file /home/amelnik/rep/MyServerName/server/data/languages.js [ INFO ] Successfully updated Language data. Requesting data from https://raw.githubusercontent.com/datasets/country-list/master/data.csv Writing to file /home/amelnik/rep/MyServerName/server/data/countries.js [ INFO ] Successfully updated Country data. [ INFO ] Widgets already exists in model AndroidCategory [ INFO ] Sports already exists in model AndroidCategory [ INFO ] Personalization already exists in model AndroidCategory [ INFO ] Live Wallpaper already exists in model AndroidCategory [ INFO ] Finance already exists in model AndroidCategory [ INFO ] Business already exists in model AndroidCategory [ INFO ] Weather already exists in model AndroidCategory [ INFO ] Social already exists in model AndroidCategory [ INFO ] News & Magazines already exists in model AndroidCategory [ INFO ] Lifestyle already exists in model AndroidCategory [ INFO ] Entertainment already exists in model AndroidCategory [ INFO ] Books & Reference already exists in model AndroidCategory [ INFO ] Travel & Local already exists in model AndroidCategory [ INFO ] Shopping already exists in model AndroidCategory [ INFO ] Music & Audio already exists in model AndroidCategory [ INFO ] Libraries & Demo already exists in model AndroidCategory [ INFO ] Education already exists in model AndroidCategory [ INFO ] Transportation already exists in model AndroidCategory [ INFO ] Productivity already exists in model AndroidCategory [ INFO ] Medical already exists in model AndroidCategory [ INFO ] Health & Fitness already exists in model AndroidCategory [ INFO ] Communication already exists in model AndroidCategory [ INFO ] Tools already exists in model AndroidCategory [ INFO ] Photography already exists in model AndroidCategory [ INFO ] Media & Video already exists in model AndroidCategory [ INFO ] Games already exists in model AndroidCategory [ INFO ] Comics already exists in model AndroidCategory [ INFO ] Weather already exists in model IosCategory [ INFO ] Reference already exists in model IosCategory [ INFO ] Music already exists in model IosCategory [ INFO ] Food & Drink already exists in model IosCategory [ INFO ] Business already exists in model IosCategory [ INFO ] Utilities already exists in model IosCategory [ INFO ] Productivity already exists in model IosCategory [ INFO ] Medical already exists in model IosCategory [ INFO ] Finance already exists in model IosCategory [ INFO ] Books already exists in model IosCategory [ INFO ] Travel already exists in model IosCategory [ INFO ] Photo & Video already exists in model IosCategory [ INFO ] Lifestyle already exists in model IosCategory [ INFO ] Entertainment already exists in model IosCategory [ INFO ] Sports already exists in model IosCategory [ INFO ] News already exists in model IosCategory [ INFO ] Health & Fitness already exists in model IosCategory [ INFO ] Education already exists in model IosCategory [ INFO ] Social Networking already exists in model IosCategory [ INFO ] Navigation already exists in model IosCategory [ INFO ] Games already exists in model IosCategory [ INFO ] Catalogs already exists in model IosCategory [ INFO ] 4.0 already exists in model SdlVersion [ INFO ] 3.0 already exists in model SdlVersion [ INFO ] 2.0 already exists in model SdlVersion [ INFO ] 1.0 already exists in model SdlVersion [ 500 ] insertDocument :: caused by :: 11000 E11000 duplicate key error index: sdl_local.userroles.$name_1 dup key: { : "Super Admin" }

This error allways appear :(

Best Regards, Andriy

ssmereka commented 9 years ago

It is clear that you have dropped the wrong database. Just look at the console logs, they are showing you that everything already exists. And the final error is a duplicate key for the role super admin, because it already exists in the database.

...
[ INFO ] Personalization already exists in model AndroidCategory
[ INFO ] Live Wallpaper already exists in model AndroidCategory
...
[ INFO ] 1.0 already exists in model SdlVersion
[ 500 ] insertDocument :: caused by :: 11000 E11000 duplicate key error index: sdl_local.userroles.$name_1 dup key: { : "Super Admin" }

You need to drop the correct database. You can list all the Mongo DB databases using the following command:

mongo
show dbs
exit

I think the default local database for SDL server is actually sdl_local not sdl_server. Sorry I should have been more explicit in my earlier instructions. So try dropping that instead. Then rerun the start/install command.

mongo
use sdl_local
db.dropDatabase()
exit
fox start -l -- -i
CallousOdesa commented 9 years ago

Thank you very much!) Now it works. I had correctly logged in and had successfuly created app without permission errors)