-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
New Issue Checklist
- I am reporting a non-security issue.
- I agree that any contribution is under this license
- I have searched existing issues and found no duplicates.
Issue Description
When configuring authentication providers via the environment variable PARSE_SERVER_AUTH_PROVIDERS, Parse Server receives the value as a string instead of a parsed object.
As a result, built-in adapters such as the Microsoft one throw:
Error: Microsoft options are required.
The root cause is that the CLI definitions for auth lack an objectParser action, so the JSON string is not parsed when building the configuration from environment variables.
Steps to reproduce
Run Parse Server using only environment variables (no config file).
Example with Docker:
docker run --rm -p 1337:1337 \
-e PARSE_SERVER_APPLICATION_ID=app \
-e PARSE_SERVER_MASTER_KEY=master \
-e PARSE_SERVER_DATABASE_URI=mongodb://host.docker.internal:27017/parse \
-e PARSE_SERVER_URL=http://localhost:1337/parse \
-e PARSE_SERVER_AUTH_PROVIDERS='{"microsoft":{"clientId":"id","clientSecret":"secret"}}' \
parseplatform/parse-server:8.4.0
Add a simple Cloud Function:
Parse.Cloud.define('debugAuthProviders', async (req) => {
return { typeOfAuth: typeof req.config.auth };
});
Call it via REST API:
curl -X POST http://localhost:1337/parse/functions/debugAuthProviders \
-H "X-Parse-Application-Id: app" \
-H "Content-Type: application/json"
Actual Outcome
Response:
{ "result": { "typeOfAuth": "string" } }
Then, when using authData.microsoft, Parse Server throws:
Error: Microsoft options are required.
Expected Outcome
req.config.auth should be an object, not a string.
Auth adapters (Microsoft, Google, etc.) should receive the correct provider options from the parsed environment variable.
Environment
Server
- Parse Server version: 8.4.0
- Node.js version: 14.19.2
- Operating system: Linux (Azure App Service / Docker)
- Deployment: Azure Web App (containerized)
Database
- System: MongoDB
- Version: 8.0
- Host: Azure Cosmos DB (Mongo API)
Client
- SDK: JavaScript
- SDK version: 7.0.2
Logs
error: Uncaught internal server error. Microsoft options are required.
{"stack":"Error: Microsoft options are required.\n
at MicrosoftAdapter.validateOptions (/parse-server/lib/Adapters/Auth/BaseCodeAuthAdapter.js:18:13)\n
at loadAuthAdapter (/parse-server/lib/Adapters/Auth/index.js:162:13)\n
at Object.getValidatorForProvider (/parse-server/lib/Adapters/Auth/index.js:182:25)\n
at /parse-server/lib/Auth.js:439:44"}
Additional Context & Proposed Fix
The environment variable PARSE_SERVER_AUTH_PROVIDERS is correctly set and valid JSON.
However, auth is declared in src/Options/index.js as a plain object type, so the generator does not include an objectParser in Definitions.js.
Suggested change
export interface AuthAdapter {
enabled: ?boolean;
}
+
+export interface AuthProvidersOptions {
+ [string]: AuthAdapter;
+}
- auth: ?{ [string]: AuthAdapter };
+ auth: ?AuthProvidersOptions;
This causes the generated Definitions.js to include:
auth: {
env: 'PARSE_SERVER_AUTH_PROVIDERS',
action: parsers.objectParser,
default: {}
}
✅ Backward compatible
✅ Fixes adapter initialization
✅ Matches the documented “stringified JSON” expectation
I’m happy to open a PR with the change and related tests once confirmed.