mirror of
https://github.com/parse-community/parse-server
synced 2026-08-09 13:03:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
522abdf606 | ||
|
|
740332bc81 | ||
|
|
82e183cbc9 | ||
|
|
44ee117327 | ||
|
|
a58c0dcd01 | ||
|
|
523fa3149e | ||
|
|
4b48e01f4b | ||
|
|
78b20d3b43 | ||
|
|
859333b311 | ||
|
|
f05fb7d9fd | ||
|
|
774de7b4c6 | ||
|
|
dc1909cbf5 | ||
|
|
585770ddc4 | ||
|
|
c34b6b9bf4 | ||
|
|
7c88d16ef0 | ||
|
|
d2fbb7c4f6 | ||
|
|
82309f7b66 | ||
|
|
66184ed645 | ||
|
|
67340f1353 | ||
|
|
dfe68237a2 | ||
|
|
49acd65520 | ||
|
|
a9aed0cacd | ||
|
|
ec8ce3c479 | ||
|
|
2f2a8062ce | ||
|
|
0bad16d34c |
@@ -20,6 +20,7 @@ function Config(applicationId, mount) {
|
||||
this.dotNetKey = cacheInfo.dotNetKey;
|
||||
this.restAPIKey = cacheInfo.restAPIKey;
|
||||
this.fileKey = cacheInfo.fileKey;
|
||||
this.facebookAppIds = cacheInfo.facebookAppIds;
|
||||
this.mount = mount;
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -44,14 +44,16 @@ ExportAdapter.prototype.connect = function() {
|
||||
|
||||
// Returns a promise for a Mongo collection.
|
||||
// Generally just for internal use.
|
||||
var joinRegex = /^_Join:[A-Za-z0-9_]+:[A-Za-z0-9_]+/;
|
||||
var otherRegex = /^[A-Za-z][A-Za-z0-9_]*$/;
|
||||
ExportAdapter.prototype.collection = function(className) {
|
||||
if (className !== '_User' &&
|
||||
className !== '_Installation' &&
|
||||
className !== '_Session' &&
|
||||
className !== '_SCHEMA' &&
|
||||
className !== '_Role' &&
|
||||
!className.match(/^_Join:[A-Za-z0-9_]+:[A-Za-z0-9_]+/) &&
|
||||
!className.match(/^[A-Za-z][A-Za-z0-9_]*$/)) {
|
||||
!joinRegex.test(className) &&
|
||||
!otherRegex.test(className)) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,
|
||||
'invalid className: ' + className);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
A Parse.com API compatible router package for Express
|
||||
|
||||
Read the announcement blog post here: http://blog.parse.com/announcements/introducing-parse-server-and-the-database-migration-tool/
|
||||
|
||||
Read the migration guide here: https://parse.com/docs/server/guide#migrating
|
||||
|
||||
There is a development wiki here on GitHub: https://github.com/ParsePlatform/parse-server/wiki
|
||||
|
||||
---
|
||||
|
||||
#### Basic options:
|
||||
@@ -11,6 +17,7 @@ A Parse.com API compatible router package for Express
|
||||
* masterKey (required) - The master key to use for overriding ACL security
|
||||
* cloud - The absolute path to your cloud code main.js file
|
||||
* fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse.
|
||||
* facebookAppIds - An array of valid Facebook application IDs.
|
||||
|
||||
#### Client key options:
|
||||
|
||||
@@ -32,7 +39,7 @@ The client keys used with Parse are no longer necessary with parse-server. If y
|
||||
|
||||
You can create an instance of ParseServer, and mount it on a new or existing Express website:
|
||||
|
||||
```
|
||||
```js
|
||||
var express = require('express');
|
||||
var ParseServer = require('parse-server').ParseServer;
|
||||
|
||||
@@ -81,4 +88,4 @@ You can also set up an app on Parse, providing the connection string for your mo
|
||||
|
||||
### Not supported
|
||||
|
||||
* Push - We did not rebuild a new push delivery system for parse-server, but we are open to working on one together with the community.
|
||||
* Push - We did not rebuild a new push delivery system for parse-server, but we are open to working on one together with the community.
|
||||
|
||||
+2
-3
@@ -219,7 +219,7 @@ RestWrite.prototype.handleFacebookAuthData = function() {
|
||||
return facebook.validateUserId(facebookData.id,
|
||||
facebookData.access_token)
|
||||
.then(() => {
|
||||
return facebook.validateAppId(process.env.FACEBOOK_APP_ID,
|
||||
return facebook.validateAppId(this.config.facebookAppIds,
|
||||
facebookData.access_token);
|
||||
}).then(() => {
|
||||
// Check if this user already exists
|
||||
@@ -283,8 +283,7 @@ RestWrite.prototype.transformUser = function() {
|
||||
'action': 'login',
|
||||
'authProvider': 'password'
|
||||
},
|
||||
restricted: false,
|
||||
expiresAt: 0
|
||||
restricted: false
|
||||
};
|
||||
var create = new RestWrite(this.config, Auth.master(this.config),
|
||||
'_Session', null, sessionData);
|
||||
|
||||
@@ -138,6 +138,7 @@ Schema.prototype.validateField = function(className, key, type, freeze) {
|
||||
|
||||
var expected = this.data[className][key];
|
||||
if (expected) {
|
||||
expected = (expected === 'map' ? 'object' : expected);
|
||||
if (expected === type) {
|
||||
return Promise.resolve(this);
|
||||
} else {
|
||||
@@ -282,6 +283,7 @@ function getType(obj) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
return type;
|
||||
case 'map':
|
||||
case 'object':
|
||||
if (!obj) {
|
||||
return undefined;
|
||||
|
||||
+7
-2
@@ -16,10 +16,15 @@ function validateUserId(userId, access_token) {
|
||||
}
|
||||
|
||||
// Returns a promise that fulfills iff this app id is valid.
|
||||
function validateAppId(appId, access_token) {
|
||||
function validateAppId(appIds, access_token) {
|
||||
if (!appIds.length) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
'Facebook auth is not configured.');
|
||||
}
|
||||
return graphRequest('app?access_token=' + access_token)
|
||||
.then((data) => {
|
||||
if (data && data.id == appId) {
|
||||
if (data && appIds.indexOf(data.id) != -1) {
|
||||
return;
|
||||
}
|
||||
throw new Parse.Error(
|
||||
|
||||
@@ -80,7 +80,7 @@ router.post('/files', function(req, res, next) {
|
||||
|
||||
// TODO: do we need to allow crossdomain and method override?
|
||||
router.post('/files/:filename',
|
||||
bodyParser.raw({type: '*/*'}),
|
||||
bodyParser.raw({type: '*/*', limit: '20mb'}),
|
||||
middlewares.handleParseHeaders,
|
||||
processCreate);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ addParseCloud();
|
||||
// "cloud": relative location to cloud code to require
|
||||
// "appId": the application id to host
|
||||
// "masterKey": the master key for requests to this app
|
||||
// "facebookAppIds": an array of valid Facebook Application IDs, required
|
||||
// if using Facebook login
|
||||
// "collectionPrefix": optional prefix for database collection names
|
||||
// "fileKey": optional key from Parse dashboard for supporting older files
|
||||
// hosted by Parse
|
||||
@@ -59,9 +61,15 @@ function ParseServer(args) {
|
||||
javascriptKey: args.javascriptKey || '',
|
||||
dotNetKey: args.dotNetKey || '',
|
||||
restAPIKey: args.restAPIKey || '',
|
||||
fileKey: args.fileKey || 'invalid-file-key'
|
||||
fileKey: args.fileKey || 'invalid-file-key',
|
||||
facebookAppIds: args.facebookAppIds || []
|
||||
};
|
||||
|
||||
// To maintain compatibility. TODO: Remove in v2.1
|
||||
if (process.env.FACEBOOK_APP_ID) {
|
||||
cache.apps[args.appId]['facebookAppIds'].push(process.env.FACEBOOK_APP_ID);
|
||||
}
|
||||
|
||||
// Initialize the node client SDK automatically
|
||||
Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey);
|
||||
|
||||
|
||||
+5
-2
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "parse-server",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.3",
|
||||
"description": "An express module providing a Parse-compatible API server",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ParsePlatform/parse-server"
|
||||
},
|
||||
"license": "BSD",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"bcrypt": "~0.8",
|
||||
"body-parser": "~1.12.4",
|
||||
@@ -25,5 +25,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "TESTING=1 jasmine"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ function transformKeyValue(schema, className, restKey, restValue, options) {
|
||||
case '_session_token':
|
||||
key = '_session_token';
|
||||
break;
|
||||
case 'expiresAt':
|
||||
case '_expiresAt':
|
||||
key = '_expiresAt';
|
||||
timeField = true;
|
||||
break;
|
||||
case '_rperm':
|
||||
case '_wperm':
|
||||
return {key: key, value: restValue};
|
||||
@@ -628,6 +633,7 @@ function untransformObject(schema, className, mongoObject) {
|
||||
restObject['password'] = mongoObject[key];
|
||||
break;
|
||||
case '_acl':
|
||||
case '_email_verify_token':
|
||||
case '_perishable_token':
|
||||
break;
|
||||
case '_session_token':
|
||||
@@ -641,6 +647,10 @@ function untransformObject(schema, className, mongoObject) {
|
||||
case '_created_at':
|
||||
restObject['createdAt'] = Parse._encode(new Date(mongoObject[key])).iso;
|
||||
break;
|
||||
case 'expiresAt':
|
||||
case '_expiresAt':
|
||||
restObject['expiresAt'] = Parse._encode(new Date(mongoObject[key])).iso;
|
||||
break;
|
||||
case '_auth_data_anonymous':
|
||||
restObject['authData'] = restObject['authData'] || {};
|
||||
restObject['authData']['anonymous'] = mongoObject[key];
|
||||
|
||||
@@ -55,6 +55,9 @@ function handleLogIn(req) {
|
||||
user.sessionToken = token;
|
||||
delete user.password;
|
||||
|
||||
var expiresAt = new Date();
|
||||
expiresAt.setFullYear(expiresAt.getFullYear() + 1);
|
||||
|
||||
var sessionData = {
|
||||
sessionToken: token,
|
||||
user: {
|
||||
@@ -67,7 +70,7 @@ function handleLogIn(req) {
|
||||
'authProvider': 'password'
|
||||
},
|
||||
restricted: false,
|
||||
expiresAt: 0,
|
||||
expiresAt: Parse._encode(expiresAt).iso,
|
||||
installationId: req.info.installationId
|
||||
};
|
||||
var create = new RestWrite(req.config, Auth.master(req.config),
|
||||
|
||||
Reference in New Issue
Block a user