https://github.com/leaonline/ddp-login-handler
Authenticate a remote DDP connect using an accessToken and an OAuth service
https://github.com/leaonline/ddp-login-handler
connection ddp meteor microservices oauth2
Last synced: about 2 months ago
JSON representation
Authenticate a remote DDP connect using an accessToken and an OAuth service
- Host: GitHub
- URL: https://github.com/leaonline/ddp-login-handler
- Owner: leaonline
- License: mit
- Created: 2019-10-14T15:52:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2026-02-06T12:48:32.000Z (4 months ago)
- Last Synced: 2026-02-06T20:37:49.507Z (4 months ago)
- Topics: connection, ddp, meteor, microservices, oauth2
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Meteor DDP Login Handler
[](https://github.com/leaonline/ddp-login-handler/actions/workflows/tests.yml)
[](https://github.com/leaonline/ddp-login-handler/actions/workflows/codeql-analysis.yml)
[](https://meteor.com)

Authenticate a remote DDP connect using an accessToken and a custom OAuth2
service.
This allows to make calls via DDP connection in behalf of a user, that is
registered on a remote Accounts server.
## Usage
The handler needs to make a call to your OAuth2 server's identity URL (the one
that is used to retrieve user credentials **after** the workflow has completed
successfully).
If the OAuth2 server responds with data (ususally an `id` and `login` or
`username` field) it will add the user to the users collection and also sets the
DDP session's user to it.
**Example setup:**
```js
/* global ServiceConfiguration */
import { Meteor } from 'meteor/meteor'
import { Accounts } from 'meteor/accounts-base'
import { HTTP } from 'meteor/http'
import {
defaultDDPLoginName,
getOAuthDDPLoginHandler
} from 'meteor/leaonline:ddp-login-handler'
Meteor.startup(() => {
setupOAuth()
})
function setupOAuth () {
const { oauth } = Meteor.settings
ServiceConfiguration.configurations.upsert(
{ service: 'lea' },
{
$set: {
loginStyle: 'popup',
clientId: oauth.clientId,
secret: oauth.secret,
dialogUrl: oauth.dialogUrl,
accessTokenUrl: oauth.accessTokenUrl,
identityUrl: oauth.identityUrl,
redirectUrl: oauth.redirectUrl
}
}
)
const loginHandler = getOAuthDDPLoginHandler({
identityUrl: oauth.identityUrl,
httpGet: (url, requestOptions) => HTTP.get(url, requestOptions),
debug: console.debug
})
Accounts.registerLoginHandler(defaultDDPLoginName, loginHandler)
}
```
## Development, running tests
To run the tests you can use the following line on your terminal:
```bash
TEST_WATCH=1 TEST_CLIENT=0 meteor test-packages ./ --driver-package meteortesting:mocha
```
## LICENSE
MIT, see [LICENSE](./LICENSE) file