# Share security signals

> Tell other systems within seconds when an agent is stopped or a session ends, and let your workforce provider's events end access here.

Signals run both ways. **Out:** a SaaS app or SIEM that relies on your realm hears within seconds that an agent was
stopped or a user's session ended, and cuts its own access to match. **In:** when your workforce provider disables
someone, their access here ends at once: sessions, tokens and offline grants, and the agents they own are
quarantined. This guide is for security teams connecting the realm to those systems.

**Before you start:**

- **Who can do it:** a realm administrator (a group holding `RealmOwner`).
- **Where:** today this is done through the API, with your session in `$CVYUH_SESSION`
  ([Call the API](/develop/api/)).
- **What you need:** for receiving, your provider's issuer and key set address, and a way to link each of your users
  to their identity there.

## Send signals to another system

<Steps>

1. Turn the transmitter on:

   ```sh
   curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "ssfEnabled": true }'
   ```

2. Register the receiving system as a client that may manage streams:

   ```sh
   curl -X POST "https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=siem" \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "status": "active", "clientName": "SIEM",
           "tokenEndpointAuthMethod": "client_secret_basic",
           "clientSecret": "<a long random secret>",
           "grantTypes": ["client_credentials"],
           "scopes": ["ssf.manage"], "defaultScopes": ["ssf.manage"],
           "allowedResources": ["https://foobar.cvyuh.com/ssf"],
           "defaultAudience": "https://foobar.cvyuh.com/ssf" }'
   ```

3. Give it its credentials. It gets a token, then makes its own stream, naming where to push and which events it
   wants:

   ```sh
   curl https://foobar.cvyuh.com/oauth2/token -u "siem:<secret>" \
     -d grant_type=client_credentials -d scope=ssf.manage

   curl https://foobar.cvyuh.com/oauth2/ssf/stream \
     -H "Authorization: Bearer $ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{ "delivery": { "method": "urn:ietf:rfc:8935",
                         "endpoint_url": "https://siem.example.com/ssf/events" },
           "events_requested": [
             "https://schemas.openid.net/secevent/risc/event-type/account-disabled" ] }'
   ```

4. It adds the users and agents it cares about at `https://foobar.cvyuh.com/oauth2/ssf/subjects/add`, and from then
   on receives signed events by push.

</Steps>

<Aside type="tip" title="Drop duplicates">
  A push is retried once on a server error, so a receiver may see an event twice. It should drop any event whose
  `jti` it has seen.
</Aside>

## Receive signals from your workforce provider

<Steps>

1. Register the provider:

   ```sh
   curl -X POST "https://foobar.cvyuh.com/api/v0/am/objects/v1/ssfTransmitter?id=workforce" \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "issuer": "https://login.partner.example",
           "jwksUri": "https://login.partner.example/keys",
           "status": "active",
           "eventsAccepted": [
             "https://schemas.openid.net/secevent/risc/event-type/account-disabled",
             "https://schemas.openid.net/secevent/risc/event-type/credential-compromise",
             "https://schemas.openid.net/secevent/caep/event-type/session-revoked" ],
           "onAccountDisabled": "revoke",
           "onOwnerDisabled": "quarantine" }'
   ```

   `onAccountDisabled: revoke` ends everything the user holds but leaves the account alone; `deactivate` also sets it
   inactive. `onOwnerDisabled: quarantine` stops the agents they own; `none` leaves them.

2. Link each user to their identity at the provider, as in
   [Accept a partner's identity](../partners/accept-a-partner-identity/).

3. Give the provider the push address: `https://foobar.cvyuh.com/oauth2/ssf/receive/workforce`.

</Steps>

## Check it worked

- **Out:** the receiving system asks for a verification event at `https://foobar.cvyuh.com/oauth2/ssf/verify`, and receives it.
- **In:** disable a test user at the provider. Their sessions here end, their tokens are refused, and the agents they
  own read `quarantined`. On the trail, their sessions end as `LOGOUT_ALL` and each agent's move as
  `AGENT_QUARANTINED`, naming the provider.

If either direction stays silent, see the troubleshooting in [Send signals](../../signals/shared-signals/#troubleshooting)
and [Receive signals](../../signals/receive-signals/#troubleshooting).

## Undo it

Delete the stream (`DELETE https://foobar.cvyuh.com/oauth2/ssf/stream?stream_id=…`) or set `ssfEnabled` to `false`. Set the `ssfTransmitter`'s
`status` to `inactive` to refuse its events.

## Related

- [Send signals](../../signals/shared-signals/): every event and endpoint.
- [Receive signals](../../signals/receive-signals/): what the realm does with each event.
- [What can be revoked](/gateway/revocation/what-can-be-revoked/): what a received signal revokes.
