<commit_before>---
layout: default
title: CAS - Releasing Principal Id
---

# Principal-Id Attribute

The service registry component of CAS has the ability to allow for configuration of a
`usernameAttributeProvider` to be returned for the given registered service. This component controls
what should be the designated user identifier that is returned to the application.

* Ensure the attribute is available and resolved for the principal
* Set the `usernameAttributeProvider` property of the given service to once of the attribute providers.
* A number of providers are able to perform canonicalization on the final user id returned to transform it
into uppercase/lowercase. This is noted by the `canonicalizationMode` whose allowed values are `UPPER`, `LOWER` or `NONE`.

## Default

The default configuration which need not explicitly be defined, simply returns the resolved
principal id as the username for this service.

```json
{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "sample",
  "name" : "sample",
  "id" : 100,
  "description" : "sample",
  "usernameAttributeProvider" : {
    "@class" : "org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider",
    "canonicalizationMode" : "NONE"
  }
}
```

If you do not need to adjust the behavior of this provider (i.e. to modify the `canonicalization` mode),
then you can leave out this block entirely.

## Encrypted

Most if not all providers are able to encrypt the resolved username, assuming the service definition is given a public key.
<commit_msg>[no ci]<commit_after>---
layout: default
title: CAS - Releasing Principal Id
---

# Principal-Id Attribute

The service registry component of CAS has the ability to allow for configuration of a
`usernameAttributeProvider` to be returned for the given registered service. This component controls
what should be the designated user identifier that is returned to the application.

* Ensure the attribute is available and resolved for the principal
* Set the `usernameAttributeProvider` property of the given service to one of the attribute providers.
* A number of providers are able to perform canonicalization on the final user id returned to transform it
into uppercase/lowercase. This is noted by the `canonicalizationMode` whose allowed values are `UPPER`, `LOWER` or `NONE`.

## Default

The default configuration which need not explicitly be defined, simply returns the resolved
principal id as the username for this service.

```json
{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "sample",
  "name" : "sample",
  "id" : 100,
  "description" : "sample",
  "usernameAttributeProvider" : {
    "@class" : "org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider",
    "canonicalizationMode" : "NONE"
  }
}
```

If you do not need to adjust the behavior of this provider (i.e. to modify the `canonicalization` mode),
then you can leave out this block entirely.

## Encrypted

Most if not all providers are able to encrypt the resolved username, assuming the service definition is given a public key.

{'fraction_non_alphanumeric': 0.07421748951274605, 'fraction_numerical': 0.001936108422071636, 'mean_word_length': 4.656934306569343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7251896', 'n_tokens_mistral': 801, 'n_tokens_neox': 775, 'n_words': 389}