How to integrate couchbase with spring security as a session store with Spring boot version 2.7.0

How to integrate couchbase with spring security as a session store with Spring boot version 2.7.0.

We are using spring boot 2.7.0, and we are trying to migrate session storage to couchbase from in memory. and we are facing issues as there is no suitable documents available on internet. So kindly help us with this.

The couchbase java sdk documentation can be found here on the internet.

This document is silent about integrating couchbase with spring security classes like SecurityConfig, Oauth2Config.

Currently this is the error…

DEBUG com.couchbase.service - [com.couchbase.service][ServiceStateChangedEvent] Service changed state from CONNECTING to CONNECTED {“coreId”:“0x7e158a9700000001”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.node - [com.couchbase.node][NodeStateChangedEvent] Node changed state from CONNECTING to DEGRADED {“coreId”:“0x7e158a9700000001”,“managerPort”:“8091”,“remote”:“172.16.62.81”}
DEBUG com.couchbase.io - [com.couchbase.io][SaslMechanismsSelectedEvent] SASL Mechanism SCRAM_SHA512 selected. Allowed: [SCRAM_SHA1, SCRAM_SHA256, SCRAM_SHA512] {“bucket”:“sessionstore”,“coreId”:“0x7e158a9700000001”,“local”:“/172.16.172.80:64160”,“remote”:“/172.16.62.81:11210”}
DEBUG com.couchbase.io - [com.couchbase.io][SaslMechanismsSelectedEvent] SASL Mechanism SCRAM_SHA512 selected. Allowed: [SCRAM_SHA1, SCRAM_SHA256, SCRAM_SHA512] {“coreId”:“0x7e158a9700000001”,“local”:“/172.16.172.80:64158”,“remote”:“/172.16.62.81:11210”}
DEBUG com.couchbase.request - [com.couchbase.request][RequestRetryScheduledEvent][512ms] Request CarrierGlobalConfigRequest retry scheduled per RetryStrategy (Reason: ENDPOINT_NOT_AVAILABLE) {“completed”:false,“coreId”:“0x7e158a9700000001”,“idempotent”:true,“lastDispatchedTo”:“172.16.62.81”,“requestId”:2,“requestType”:“CarrierGlobalConfigRequest”,“retried”:11,“retryReasons”:[“ENDPOINT_NOT_AVAILABLE”,“NODE_NOT_AVAILABLE”],“service”:{“opaque”:“0x9”,“target”:“172.16.62.81”,“type”:“kv”,“vbucket”:0},“timeoutMs”:10000}
DEBUG com.couchbase.io - [com.couchbase.io][FeaturesNegotiatedEvent][226ms] Negotiated [MUTATION_SEQNO] {“coreId”:“0x7e158a9700000001”,“local”:“/172.16.172.80:64158”,“remote”:“/172.16.62.81:11210”}
DEBUG com.couchbase.io - [com.couchbase.io][FeaturesNegotiatedEvent][226ms] Negotiated [MUTATION_SEQNO] {“bucket”:“sessionstore”,“coreId”:“0x7e158a9700000001”,“local”:“/172.16.172.80:64160”,“remote”:“/172.16.62.81:11210”}
DEBUG com.couchbase.config - [com.couchbase.config][BucketConfigUpdatedEvent] Bucket configuration updated: CouchbaseBucketConfig{name=‘sessionstore’, locator=VBUCKET, uri=‘/pools/default/buckets/sessionstore?bucket_uuid=b6a492eb63d7a3564bd43f9945103c7e’, streamingUri=‘/pools/default/bucketsStreaming/sessionstore?bucket_uuid=b6a492eb63d7a3564bd43f9945103c7e’, nodes=[NodeInfo{host=chgvasrv814.msccruises.com, ports={MANAGER=8091, KV=11210, VIEWS=8092, QUERY=8093}, securePorts={MANAGER=18091, KV=11207, VIEWS=18092, QUERY=18093}, aa={}, configPort=0, nodeIdentifier=NodeIdentifier{address=chgvasrv814.msccruises.com, managerPort=8091}}], partitionInfo=PartitionInfo{numberOfReplicas=1, partitionHosts=[chgvasrv814.msccruises.com:11210], partitions=[[0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1], [0,-1],




DEBUG com.couchbase.endpoint - [com.couchbase.endpoint][EndpointStateChangedEvent] Endpoint changed state from CONNECTED to DISCONNECTING {“circuitBreaker”:“DISABLED”,“coreId”:“0x7e158a9700000001”,“local”:“172.16.172.80:64159”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.service - [com.couchbase.service][ServiceStateChangedEvent] Service changed state from CONNECTED to DISCONNECTING {“coreId”:“0x7e158a9700000001”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.endpoint - [com.couchbase.endpoint][EndpointStateChangedEvent] Endpoint changed state from DISCONNECTING to DISCONNECTED {“circuitBreaker”:“DISABLED”,“coreId”:“0x7e158a9700000001”,“local”:“172.16.172.80:64159”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.service - [com.couchbase.service][ServiceStateChangedEvent] Service changed state from DISCONNECTING to DISCONNECTED {“coreId”:“0x7e158a9700000001”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.service - [com.couchbase.service][ServiceStateChangedEvent] Service changed state from DISCONNECTED to IDLE {“coreId”:“0x7e158a9700000001”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.endpoint - [com.couchbase.endpoint][EndpointDisconnectedEvent][1034us] Endpoint disconnected successfully {“circuitBreaker”:“DISABLED”,“coreId”:“0x7e158a9700000001”,“local”:“172.16.172.80:64159”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
DEBUG com.couchbase.service - [com.couchbase.service][ServiceRemovedEvent][2012us] Service removed from Node {“coreId”:“0x7e158a9700000001”,“remote”:“172.16.62.81:8091”,“type”:“MANAGER”}
INFO com.couchbase.node - [com.couchbase.node][NodeDisconnectedEvent][2632us] Node disconnected {“coreId”:“0x7e158a9700000001”,“managerPort”:“8091”,“remote”:“172.16.62.81”}
DEBUG com.couchbase.core - [com.couchbase.core][ReconfigurationCompletedEvent][20ms] Reconfiguration attempt completed. {“coreId”:“0x7e158a9700000001”}
INFO com.couchbase.core - [com.couchbase.core][BucketOpenedEvent][11s] Opened bucket “sessionstore” {“coreId”:“0x7e158a9700000001”}
DEBUG com.couchbase.config - [com.couchbase.config][IndividualGlobalConfigLoadFailedEvent][1101ms] Fetching a global config from node “172.16.62.81” failed, but ignored on purpose. {“coreId”:“0x7e158a9700000001”}
com.couchbase.client.core.error.ConfigException: Caught exception while loading global config.
at com.couchbase.client.core.config.loader.GlobalLoader.lambda$load$3(GlobalLoader.java:72)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)
at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)
at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)

Refer to the SecurityConfig and Oauth2Config documentatation for customization.