parse-community / parse-community/parse-server
Keycloak authentication
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
Hi
my problem is that I can't find out how to login with keycloak, I searched a lot and couldn't make it work.
I know in backend, parse server should config for support Keycloak and in front user should login/signup with method linkWith. but the problem is that I get [403] -> unauthorized error with any payload.
Steps to reproduce
Backend:
const fs = require('fs');
const express = require('express');
const ParseServer = require('parse-server').ParseServer;
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(express.text());
const api = new ParseServer({
databaseURI: 'mongodb://admin:admin@localhost:27017/', // Connection string for your MongoDB database
cloud: './cloud/main.js', // Path to your Cloud Code
appId: 'myAppId',
masterKey: 'myMasterKey', // Keep this key secret!
fileKey: 'optionalFileKey',
serverURL: 'http://localhost:8080/parse', // Don't forget to change to https if needed
auth: {
keycloak: {
config: {
"realm": "BenjaminR",
"auth-server-url": "http://localhost:8081/",
"ssl-required": "external",
"resource": "my-kc",
"verify-token-audience": true,
"credentials": {
"secret": "KVuKQ47Re25rewsd0RE8lUlaziDtfcDSH"
},
"use-resource-role-mappings": true,
"confidential-port": 0
}
}
}
});
app.use(cors('*'));
// Serve the Parse API on the /parse URL prefix
app.use(cors('*'));
app.use('/parse', api);
app.listen(8080, function() {
console.log('parse-server-example running on port 1337.');
});
Client:
const token = 'keycloak valid and tested token'
const user = new Parse.User();
await user.linkWith('keycloak', {
authData: {
access_token: token,
id: "cwq613e9-a220-2g7a-bfx7-72722978wc02",
roles: ["roles..."],
groups: ["user-groups"]
}
});
Actual Outcome
{
"error": "unauthorized"
}
Expected Outcome
expected response in document
Server
- Parse Server version:
5.2.8 - Operating system:
windows 10 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
6.0.2 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local (docker)
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
javascript - SDK version:
3.4.4
Logs
no log
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the server's auth.keycloak configuration and the JavaScript Parse.User.linkWith call shown in the issue; reproduce the 403 using the supplied token and Parse Server 5.2.8 setup. Trace the authentication entry point and compare the token fields with the Keycloak integration requirements; done means the cause is isolated and a verified expected response or configuration is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100