ngageoint / mage-server

Mobile Awareness GEOINT Environment Server
Apache License 2.0
88 stars 46 forks source link

Setup broken on master #52

Closed JoshMcCullough closed 5 years ago

JoshMcCullough commented 5 years ago

FYI setup seems to be broken on master. I accidentally grabbed master instead of 5.2.5, and noticed that during first run / setup, after entering the initial device id/uid, I get a 401.


Unfortunately I am having the same issue with 5.2.5 -- fresh install on a fresh Mongo v3.4.20 instance. Here is the log:

2019-06-15T02:28:53.618Z - info: Starting MAGE Server ... 2019-06-15T02:28:54.126Z - info: setting up provision uid 2019-06-15T02:28:54.836Z - info: Using '/var/lib/mage/attachments' as base directory for feature attachments. 2019-06-15T02:28:54.836Z - info: Using '/var/lib/mage/icons' as base directory for MAGE icons. 2019-06-15T02:28:54.845Z - info: intializing database models ... 2019-06-15T02:28:54.845Z - info: intializing database model cappedLocation ... 2019-06-15T02:28:54.845Z - info: intializing database model counter ... 2019-06-15T02:28:54.845Z - info: intializing database model device ... 2019-06-15T02:28:54.845Z - info: intializing database model event ... 2019-06-15T02:28:54.845Z - info: intializing database model feature ... 2019-06-15T02:28:54.846Z - info: intializing database model icon ... 2019-06-15T02:28:54.846Z - info: intializing database model layer ... 2019-06-15T02:28:54.846Z - info: intializing database model location ... 2019-06-15T02:28:54.846Z - info: intializing database model login ... 2019-06-15T02:28:54.846Z - info: intializing database model observation ... 2019-06-15T02:28:54.846Z - info: intializing database model permission ... 2019-06-15T02:28:54.846Z - info: intializing database model role ... 2019-06-15T02:28:54.846Z - info: intializing database model setting ... 2019-06-15T02:28:54.846Z - info: intializing database model team ... 2019-06-15T02:28:54.846Z - info: intializing database model token ... 2019-06-15T02:28:54.846Z - info: intializing database model user ... 2019-06-15T02:28:54.846Z - info: running database migrations in directory /opt/mage/mage-server/migrations ... 2019-06-15T02:28:54.862Z - mongoose: settings.ensureIndex({ type: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.867Z - mongoose: tokens.ensureIndex({ expirationDate: 1 }, { expireAfterSeconds: 0, background: true }, ) 2019-06-15T02:28:54.867Z - mongoose: logins.ensureIndex({ userId: 1 }, { background: true }, ) 2019-06-15T02:28:54.868Z - mongoose: locations.ensureIndex({ userId: 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.868Z - mongoose: cappedlocations.ensureIndex({ userId: 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.868Z - mongoose: users.ensureIndex({ username: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.869Z - mongoose: devices.ensureIndex({ uid: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.869Z - mongoose: layers.ensureIndex({ _id: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.869Z - mongoose: layers.ensureIndex({ _id: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.869Z - mongoose: layers.ensureIndex({ _id: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.870Z - mongoose: layers.ensureIndex({ _id: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.870Z - mongoose: roles.ensureIndex({ name: 1 }, { unique: true, background: true }, ) 2019-06-15T02:28:54.878Z - mongoose: logins.ensureIndex({ deviceId: 1 }, { background: true }, ) 2019-06-15T02:28:54.885Z - mongoose: locations.ensureIndex({ eventId: 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.892Z - mongoose: users.ensureIndex({ status: 1 }, { background: true }, ) 2019-06-15T02:28:54.900Z - mongoose: cappedlocations.ensureIndex({ eventId: 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.902Z - mongoose: locations.ensureIndex({ geometry: '2dsphere' }, { background: true }, ) 2019-06-15T02:28:54.903Z - mongoose: logins.ensureIndex({ userId: 1, deviceId: 1 }, { background: true }, ) 2019-06-15T02:28:54.904Z - mongoose: cappedlocations.ensureIndex({ 'locations.userId': 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.908Z - info: Migration 'create-initial-user-role': skip (migration already ran) 2019-06-15T02:28:54.908Z - info: Migration 'create-initial-admin-role': skip (migration already ran) 2019-06-15T02:28:54.908Z - info: Migration 'create-initial-osm-layer': skip (migration already ran) 2019-06-15T02:28:54.908Z - info: Migration '006-event-teams': skip (migration already ran) 2019-06-15T02:28:54.908Z - info: Migration '007-user-icon': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'create-user-no-edit-role': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'create-manager-role': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'add-user-device-manager-role': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'multiple-forms': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'user-role-remove-delete': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'ensure-event-indexes': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'add-role-update-delete': skip (migration already ran) 2019-06-15T02:28:54.909Z - info: Migration 'manager-role-add-user-create': skip (migration already ran) 2019-06-15T02:28:54.910Z - info: database initialized; loading plugins ... 2019-06-15T02:28:54.916Z - info: opening app for connections ... 2019-06-15T02:28:54.920Z - info: MAGE Server: listening at address 0.0.0.0 on port 4242 2019-06-15T02:28:54.921Z - mongoose: locations.ensureIndex({ 'properties.timestamp': 1 }, { background: true }, ) 2019-06-15T02:28:54.922Z - mongoose: logins.ensureIndex({ _id: 1, userId: 1, deviceId: 1 }, { background: true }, ) 2019-06-15T02:28:54.924Z - mongoose: cappedlocations.ensureIndex({ 'locations.eventId': 1 }, { sparse: true, background: true }, ) 2019-06-15T02:28:54.925Z - mongoose: locations.ensureIndex({ 'properties.timestamp': 1, _id: 1 }, { background: true }, ) 2019-06-15T02:28:54.926Z - mongoose: cappedlocations.ensureIndex({ 'locations.geometry': '2dsphere' }, { background: true }, ) 2019-06-15T02:28:54.926Z - mongoose: locations.ensureIndex({ userId: 1 }, { background: true }, ) 2019-06-15T02:28:54.927Z - mongoose: cappedlocations.ensureIndex({ 'locations.properties.timestamp': 1 }, { background: true }, ) 2019-06-15T02:28:54.928Z - mongoose: locations.ensureIndex({ 'properties.user': 1, 'properties.timestamp': 1 }, { background: true }, ) 2019-06-15T02:28:54.929Z - mongoose: cappedlocations.ensureIndex({ 'locations.properties.timestamp': 1, 'locations._id': 1 }, { background: true }, ) 2019-06-15T02:28:54.929Z - mongoose: cappedlocations.ensureIndex({ 'locations.userId': 1 }, { background: true }, ) 2019-06-15T02:28:54.931Z - mongoose: cappedlocations.ensureIndex({ 'locations.properties.user': 1, 'locations.properties.timestamp': 1 }, { background: true }, ) 2019-06-15T02:28:54.932Z - mongoose: cappedlocations.ensureIndex({ eventId: 1 }, { background: true }, ) 2019-06-15T02:28:54.932Z - mongoose: cappedlocations.ensureIndex({ 'locations.properties.timestamp': 1 }, { background: true }, ) 2019-06-15T02:28:54.933Z - mongoose: cappedlocations.ensureIndex({ 'locations.properties.timestamp': 1, eventId: 1 }, { background: true }, ) 2019-06-15T02:29:02.378Z - mongoose: tokens.findOne({ token: 'null' }, { fields: {} }, ) 2019-06-15T02:29:02.393Z - mongoose: users.count({}, {}, ) 2019-06-15T02:29:02.394Z - mongoose: settings.findOne({ type: 'disclaimer' }, { fields: {} }, ) 2019-06-15T02:29:02.488Z - mongoose: tokens.findOne({ token: 'null' }, { fields: {} }, ) 2019-06-15T02:29:02.598Z - mongoose: tokens.findOne({ token: 'null' }, { fields: {} }, ) 2019-06-15T02:29:10.848Z - mongoose: users.count({}, {}, ) 2019-06-15T02:29:10.859Z - mongoose: roles.findOne({ name: 'ADMIN_ROLE' }, { fields: {} }, ) 2019-06-15T02:29:10.875Z - mongoose: users.findOne({ username: 'admin' }, { fields: {} }, ) 2019-06-15T02:29:10.878Z - mongoose: users.findOne({ _id: ObjectId("5d0457f6a124f7519093c5b0") }, { fields: {} }, ) 2019-06-15T02:29:10.995Z - mongoose: users.insert({ lastUpdated: new Date("Sat, 15 Jun 2019 02:29:10 GMT"), createdAt: new Date("Sat, 15 Jun 2019 02:29:10 GMT"), username: 'admin', displayName: 'admin', active: true, roleId: ObjectId("5d04579ae0f2145143661ee6"), _id: ObjectId("5d0457f6a124f7519093c5b0"), authentication: { type: 'local', password: '...', security: { numberOfTimesLocked: 0, invalidLoginAttempts: 0 } }, recentEventIds: [], enabled: true, icon: { type: 'none' }, phones: [] }, , ) 2019-06-15T02:29:11.007Z - mongoose: roles.find({ _id: { '$in': [ ObjectId("5d04579ae0f2145143661ee6") ] } }, { fields: {} }, ) 2019-06-15T02:29:11.017Z - mongoose: devices.findAndModify({ uid: 'mydevice' }, [], { '$set': { description: undefined, userId: undefined, userAgent: undefined, appVersion: undefined, registered: true } }) 2019-06-15T02:29:11.235Z - mongoose: users.findOne({ username: 'admin' }, { fields: {} }, ) 2019-06-15T02:29:11.237Z - mongoose: roles.find({ _id: { '$in': [ ObjectId("5d04579ae0f2145143661ee6") ] } }, { fields: {} }, ) 2019-06-15T02:29:11.358Z - mongoose: users.findOne({ username: 'admin' }, { fields: {} }, ) 2019-06-15T02:29:11.360Z - mongoose: users.update({ _id: ObjectId("5d0457f6a124f7519093c5b0") }, { '$set': { 'authentication.security': {}, lastUpdated: new Date("Sat, 15 Jun 2019 02:29:11 GMT") } }, )

newmanw commented 5 years ago

Are you using http or https? I suspect your problem is you are using http and the MAGE_SESSION_COOKIE_SECURE environment variable is not set to false.

JoshMcCullough commented 5 years ago

Good call. I did set MAGE_SESSION_COOKIE_SECURE tofalse because we're proxying requests to the server so we don't use HTTPS internally. Are you suggesting I have to set MAGE up initially without this env var set tofalse but can re-set it afterward?

JoshMcCullough commented 5 years ago

Yeah, all good here. Thanks.

fm-davidcraig commented 5 years ago

where to you find MAGE_SESSION_COOKIE_SECURE ?

JoshMcCullough commented 5 years ago

@fm-davidcraig It's used in env.js, but you declare it when you're starting MAGE e.g. MAGE_SESSION_COOKIE_SECURE=false; npm start

newmanw commented 5 years ago

There is also a file you can source that contains a lot of valuable env variables with comments and sensible defaults.

magerc.sh