Google Cloud Pub/Sub Ticket Registry

This registry is very much an extension of the default ticket registry. The difference is that ticket operations applied to the registry are broadcasted using Google Cloud’s PubSub.

Each node keeps copies of ticket state on its own and only instructs others to keep their copy accurate by broadcasting messages and data associated with each. Each message and ticket registry instance running inside a CAS node in the cluster is tagged with a unique identifier in order to avoid endless looping behavior and recursive needless inbound operations.

:information_source: Message Ordering

This registry implementation requires you to enable message ordering via CAS settings.

Support is enabled by including the following dependency in the overlay:

1
2
3
4
5
<dependency>
    <groupId>org.apereo.cas</groupId>
    <artifactId>cas-server-support-gcp-pubsub-ticket-registry</artifactId>
    <version>${cas.version}</version>
</dependency>
1
implementation "org.apereo.cas:cas-server-support-gcp-pubsub-ticket-registry:${project.'cas.version'}"
1
2
3
4
5
6
7
8
9
dependencyManagement {
    imports {
        mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
    }
}

dependencies {
    implementation "org.apereo.cas:cas-server-support-gcp-pubsub-ticket-registry"
}
1
2
3
4
5
6
7
8
9
10
dependencies {
    /*
        The following platform references are included automatically and are listed for reference only.

        implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
        implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
        
    */
    implementation "org.apereo.cas:cas-server-support-gcp-pubsub-ticket-registry"
}

Integration support is backed by the Spring Cloud GCP project. Their reference documentation provides detailed information on how to integrate Google Cloud APIs with CAS.

To understand how to set up application default credentials, please review this page.

CAS Configuration

The following settings and properties are available from the CAS configuration catalog:

cas.ticket.registry.in-memory.crypto.encryption.keyThe encryption key.
no default
Required

The encryption key. The encryption key by default and unless specified otherwise must be randomly-generated string whose length is defined by the encryption key size setting.

Type
String
Default
none
Defined by
EncryptionRandomizedCryptoProperties
cas.ticket.registry.in-memory.crypto.signing.keyThe signing key is a string whose length is defined by the signing key size setting.
no default
RequiredSpEL

The signing key is a string whose length is defined by the signing key size setting.

Type
String
Default
none
Defined by
SigningJwtCryptoProperties
Supports
Spring Expression Language
cas.ticket.registry.in-memory.concurrencyThe estimated number of concurrently updating threads.
20

The estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.

Type
Integer
Default
20
Defined by
InMemoryTicketRegistryProperties
cas.ticket.registry.in-memory.crypto.algThe signing/encryption algorithm to use.
AES

The signing/encryption algorithm to use.

Type
String
Default
AES
Defined by
EncryptionRandomizedSigningJwtCryptographyProperties
cas.ticket.registry.in-memory.crypto.enabledWhether crypto operations are enabled.
true

Whether crypto operations are enabled.

Type
Boolean
Default
true
Defined by
EncryptionRandomizedSigningJwtCryptographyProperties
cas.ticket.registry.in-memory.crypto.encryption.key-sizeEncryption key size.
16

Encryption key size.

Type
Integer
Default
16
Defined by
EncryptionRandomizedCryptoProperties
cas.ticket.registry.in-memory.crypto.signing-enabledWhether signing encryption operations are enabled.
true

Whether signing encryption operations are enabled.

Type
Boolean
Default
true
Defined by
EncryptionRandomizedSigningJwtCryptographyProperties
cas.ticket.registry.in-memory.crypto.signing.key-sizeThe signing key size.
512

The signing key size.

Type
Integer
Default
512
Defined by
SigningJwtCryptoProperties
cas.ticket.registry.in-memory.initial-capacityThe initial capacity of the underlying memory store.
1000

The initial capacity of the underlying memory store. The implementation performs internal sizing to accommodate this many elements.

Type
Integer
Default
1000
Defined by
InMemoryTicketRegistryProperties
cas.ticket.registry.in-memory.load-factorThe load factor threshold, used to control resizing.
1

The load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.

Type
Integer
Default
1
Defined by
InMemoryTicketRegistryProperties
cas.ticket.registry.in-memory.propertiesFree-form key-value pairs to configure the specific registry with custom settings.
no default

Free-form key-value pairs to configure the specific registry with custom settings.

Type
Map<String,String>
Default
none
Defined by
InMemoryTicketRegistryProperties
spring.cloud.gcp.pubsub.binder.enabledAuto-configure Google Cloud Pub/Sub Stream Binder components.
true
Third party

Auto-configure Google Cloud Pub/Sub Stream Binder components.

Type
Boolean
Default
true
spring.cloud.gcp.pubsub.credentials.default-scopes
no default
Third party
Type
String[]
Default
none
Defined by
Credentials
spring.cloud.gcp.pubsub.emulator-hostThe host and port of the local running emulator.
no default
Third party

The host and port of the local running emulator. If provided, this will setup the client to connect against a running pub/sub emulator.

Type
String
Default
none
Defined by
GcpPubSubProperties
spring.cloud.gcp.pubsub.enabledAuto-configure Google Cloud Pub/Sub components.
true
Third party

Auto-configure Google Cloud Pub/Sub components.

Type
Boolean
Default
true
spring.cloud.gcp.pubsub.fully-qualified-subscriber-properties
no default
Third party
Type
Map<ProjectSubscriptionName,PubSubConfiguration.Subscriber>
Default
none
Defined by
GcpPubSubProperties
spring.cloud.gcp.pubsub.health.acknowledge-messagesWhether to acknowledge messages pulled from #subscription .
false
Third party

Whether to acknowledge messages pulled from #subscription.

Type
Boolean
Default
false
Defined by
PubSubHealthIndicatorProperties
spring.cloud.gcp.pubsub.health.backlog-threshold
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Health
spring.cloud.gcp.pubsub.health.executor-threads
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Health
spring.cloud.gcp.pubsub.health.lag-threshold
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Health
spring.cloud.gcp.pubsub.health.look-up-interval
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Health
spring.cloud.gcp.pubsub.health.subscriptionSubscription to health check against by pulling a message.
no default
Third party

Subscription to health check against by pulling a message.

Type
String
Default
none
Defined by
PubSubHealthIndicatorProperties
spring.cloud.gcp.pubsub.health.timeout-millisMilliseconds to wait for response from Pub/Sub before timing out.
5000
Third party

Milliseconds to wait for response from Pub/Sub before timing out.

Type
Long
Default
5000
Defined by
PubSubHealthIndicatorProperties
spring.cloud.gcp.pubsub.keep-alive-interval-minutesHow often to ping the server to keep the channel alive.
5
Third party

How often to ping the server to keep the channel alive.

Type
Integer
Default
5
Defined by
GcpPubSubProperties
spring.cloud.gcp.pubsub.project-idOverrides the GCP project ID specified in the Core module.
no default
Third party

Overrides the GCP project ID specified in the Core module.

Type
String
Default
none
Defined by
GcpPubSubProperties
spring.cloud.gcp.pubsub.publisher.batching.delay-threshold-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Batching
spring.cloud.gcp.pubsub.publisher.batching.element-count-threshold
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Batching
spring.cloud.gcp.pubsub.publisher.batching.enabled
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Batching
spring.cloud.gcp.pubsub.publisher.batching.flow-control.limit-exceeded-behavior
no default
Third party
Type
FlowController.LimitExceededBehavior
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.publisher.batching.flow-control.max-outstanding-element-count
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.publisher.batching.flow-control.max-outstanding-request-bytes
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.publisher.batching.request-byte-threshold
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Batching
spring.cloud.gcp.pubsub.publisher.enable-message-ordering
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.endpoint
no default
Third party
Type
String
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.executor-accept-tasks-after-context-close
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.executor-await-termination-millis
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.executor-threads
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.executor-wait-for-tasks-to-complete-on-shutdown
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.publisher.retry.initial-retry-delay-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.initial-rpc-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.jittered
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.max-attempts
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.max-retry-delay-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.max-rpc-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.retry-delay-multiplier
no default
Third party
Type
Double
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.rpc-timeout-multiplier
no default
Third party
Type
Double
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.retry.total-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.publisher.universe-domain
no default
Third party
Type
String
Default
none
Defined by
PubSubConfiguration$Publisher
spring.cloud.gcp.pubsub.reactive.enabledAuto-configure Google Cloud Pub/Sub Reactive components.
true
Third party

Auto-configure Google Cloud Pub/Sub Reactive components.

Type
Boolean
Default
true
spring.cloud.gcp.pubsub.subscriber.executor-threads
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.flow-control.limit-exceeded-behavior
no default
Third party
Type
FlowController.LimitExceededBehavior
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.subscriber.flow-control.max-outstanding-element-count
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.subscriber.flow-control.max-outstanding-request-bytes
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$FlowControl
spring.cloud.gcp.pubsub.subscriber.fully-qualified-name
no default
Third party
Type
String
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.max-ack-extension-period
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.max-acknowledgement-threads
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.max-duration-per-ack-extension
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.min-duration-per-ack-extension
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.parallel-pull-count
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.pull-endpoint
no default
Third party
Type
String
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.retry.initial-retry-delay-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.initial-rpc-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.jittered
no default
Third party
Type
Boolean
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.max-attempts
no default
Third party
Type
Integer
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.max-retry-delay-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.max-rpc-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.retry-delay-multiplier
no default
Third party
Type
Double
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.rpc-timeout-multiplier
no default
Third party
Type
Double
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retry.total-timeout-seconds
no default
Third party
Type
Long
Default
none
Defined by
PubSubConfiguration$Retry
spring.cloud.gcp.pubsub.subscriber.retryable-codes
no default
Third party
Type
StatusCode.Code[]
Default
none
Defined by
PubSubConfiguration$Subscriber
spring.cloud.gcp.pubsub.subscriber.universe-domain
no default
Third party
Type
String
Default
none
Defined by
PubSubConfiguration$Subscriber

Required settings may be needed to activate or affect the feature; review them even when they have a default. Optional settings only need to be set to change a default or to turn on the behavior they control. Third party settings belong to libraries such as Spring Boot that CAS builds on; their own documentation may have more detail.

Signing & encryption

This CAS feature is able to accept signing and encryption crypto keys. In most scenarios if keys are not provided, CAS will auto-generate them. The following instructions apply if you wish to manually and beforehand create the signing and encryption keys.

Note that if you are asked to create a JWK of a certain size for the key, you are to use the following set of commands to generate the token:

1
2
wget https://raw.githubusercontent.com/apereo/cas/master/etc/jwk-gen.jar
java -jar jwk-gen.jar -t oct -s [size]

The outcome would be similar to:

1
2
3
4
5
{
  "kty": "oct",
  "kid": "...",
  "k": "..."
}

The generated value for k needs to be assigned to the relevant CAS settings. Note that keys generated via the above algorithm are processed by CAS using the Advanced Encryption Standard (AES) algorithm which is a specification for the encryption of electronic data established by the U.S. National Institute of Standards and Technology.


Groovy scripting

CAS takes advantage of Apache Groovy in forms of either embedded or external scripts that allow one to, by default, dynamically build constructs, attributes, access strategies and a lot more. To activate the functionality described here, you may need to prepare CAS to support and integrate with Apache Groovy.

Please review this guide to configure your build.

Notes on configuration

Configuration Metadata

The collection of configuration properties listed in this section are automatically generated from the CAS source and components that contain the actual field definitions, types, descriptions, modules, etc. This metadata may not always be 100% accurate, or could be lacking details and sufficient explanations.

Be Selective

This section is meant as a guide only. Do NOT copy/paste the entire collection of settings into your CAS configuration; rather pick only the properties that you need. Do NOT enable settings unless you are certain of their purpose and do NOT copy settings into your configuration only to keep them as reference. All these ideas lead to upgrade headaches, maintenance nightmares and premature aging.

YAGNI

Note that for nearly ALL use cases, declaring and configuring properties listed here is sufficient. You should NOT have to explicitly massage a CAS XML/Java/etc configuration file to design an authentication handler, create attribute release policies, etc. CAS at runtime will auto-configure all required changes for you. If you are unsure about the meaning of a given CAS setting, do NOT turn it on without hesitation. Review the codebase or better yet, ask questions to clarify the intended behavior.

Naming Convention

Property names can be specified in very relaxed terms. For instance cas.someProperty, cas.some-property, cas.some_property are all valid names. While all forms are accepted by CAS, there are certain components (in CAS and other frameworks used) whose activation at runtime is conditional on a property value, where this property is required to have been specified in CAS configuration using kebab case. This is both true for properties that are owned by CAS as well as those that might be presented to the system via an external library or framework such as Spring Boot, etc.

:information_source: Note

When possible, properties should be stored in lower-case kebab format, such as cas.property-name=value. The only possible exception to this rule is when naming actuator endpoints; The name of the actuator endpoints (i.e. ssoSessions) MUST remain in camelCase mode.

Settings and properties that are controlled by the CAS platform directly always begin with the prefix cas. All other settings are controlled and provided to CAS via other underlying frameworks and may have their own schemas and syntax. BE CAREFUL with the distinction. Unrecognized properties are rejected by CAS and/or frameworks upon which CAS depends. This means if you somehow misspell a property definition or fail to adhere to the dot-notation syntax and such, your setting is entirely refused by CAS and likely the feature it controls will never be activated in the way you intend.

Validation

Configuration properties are automatically validated on CAS startup to report issues with configuration binding, especially if defined CAS settings cannot be recognized or validated by the configuration schema. Additional validation processes are also handled via Configuration Metadata and property migrations applied automatically on startup by Spring Boot and family.

Indexed Settings

CAS settings able to accept multiple values are typically documented with an index, such as cas.some.setting[0]=value. The index [0] is meant to be incremented by the adopter to allow for distinct multiple configuration blocks.

Actuator Endpoints

The following endpoints are provided by CAS:

health
Third-party endpoint2 operationsExposed by default
1

Turn the endpoint on and expose it over the web. One entry covers every operation. By default only info, health and status are exposed.

1
2
management.endpoint.health.access=UNRESTRICTED
management.endpoints.web.exposure.include=health

Endpoints may be mapped to other paths. For example, to serve health at healthcheck:

1
management.endpoints.web.path-mapping.health=healthcheck
:information_source: Cloud Monitoring

To successfully use the Spring Cloud GCP actuator endpoints, you will also need to enable the Cloud Monitoring API.

Troubleshooting

To enable additional logging, configure the log4j configuration file to add the following levels:

1
2
3
4
5
6
...
<Logger name="com.google.cloud" level="debug" additivity="false">
    <AppenderRef ref="casConsole"/>
    <AppenderRef ref="casFile"/>
</Logger>
...