https://github.com/spurreiter/keycloak-ldap
https://github.com/spurreiter/keycloak-ldap
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/spurreiter/keycloak-ldap
- Owner: spurreiter
- License: other
- Created: 2020-10-18T18:19:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-26T20:42:13.000Z (almost 3 years ago)
- Last Synced: 2025-01-07T06:37:51.351Z (4 months ago)
- Language: JavaScript
- Size: 2.97 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @spurreiter/keycloak-ldap
A ldap stub adapter for keycloak
Connect your user store via ldap to keycloak.
Avoids the need to write SPI adapters to connect your users.
## customization
Write your own storage-adapter to your user accounts and connect those via ldap to keycloak.
Check `src/adapter/interface.js` and `src/adapter/mock.js`.
The required setup for the keycloak realm(s) can be found in `scripts/my-realm.json`.
See `src/dev.js` for usage in your own project
## example
Start the example.
```sh
node scripts/docker-build.js
node scripts/docker-run.js
# wait a minute for the container to start
node scripts/import-realm.js
npm run dev
```In `src/adapter/mockUsers.js` the default users "alice", "bob" and "charly" are available.
New users can be registered.## multi-factor-authentication
`src/mfa` contains a express router to handle generation and sending of OTP codes.
The sendMfa function as well as the temporary storage adapter for the generated OTP codes needs to be implemented.
```js
const app = express()
const {
mfaRouter,
} = require('@spurreiter/keycloak-ldap')
// create your own storage adapter - see `src/adapter/mock.js`
const adapter = new Adapter()
// your function to send the OTP code
const sendMfa = ({ destination, code, ...userattributes } ) =>
console.log({destination, code})
// mount the router
app.use('/mfa', mfaRouter({ adapter, sendMfa }))
// start the server
http.createServer(app).listen(1080, 'localhost')
```