Security and Authentication with the JavaScript Client
What You Will Learn
How to connect to an Infinispan Server using different SCRAM SASL authentication mechanisms: SCRAM-SHA-256 and SCRAM-SHA-512.
Prerequisites
-
Node.js 22+
-
An Infinispan Server running on
localhost:11222
Start an Infinispan Server with Docker or Podman:
docker run -it --rm -p 11222:11222 -e USER=admin -e PASS=password quay.io/infinispan/server:latest
|
Tip
|
You can replace docker with podman in the command above if you use Podman.
|
Step 1: Connect with SCRAM-SHA-256 Authentication
SCRAM-SHA-256 is a challenge-response mechanism with salted password hashing:
const client = await ispn.client({port: 11222, host: '127.0.0.1'}, {
cacheName: 'test',
authentication: {
enabled: true,
saslMechanism: 'SCRAM-SHA-256',
userName: 'admin',
password: 'password'
}
});
Step 2: SCRAM-SHA-512 Authentication
Use SCRAM-SHA-512 for the same mechanism with a stronger hash:
const scramClient = await ispn.client({port: 11222, host: '127.0.0.1'}, {
cacheName: 'test',
authentication: {
enabled: true,
saslMechanism: 'SCRAM-SHA-512',
userName: 'admin',
password: 'password'
}
});
Step 3: Run the Tutorial
npm run security
You should see output like:
Connecting with SCRAM-SHA-256 mechanism... SCRAM-SHA-256 auth successful: value Connecting with SCRAM-SHA-512 mechanism... SCRAM-SHA-512 auth successful: scram-value Done.
What’s Next
-
Basic cache operations for standard cache usage
-
Cache event listeners for reacting to cache changes


