Skip to content

Commit

Permalink
x-pack/filebeat/input/entityanalytics/provider/okta: add device handling
Browse files Browse the repository at this point in the history
WIP: needs validation against real API.
  • Loading branch information
efd6 committed Jul 12, 2023
1 parent 8d64c9b commit 5d58d30
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ automatic splitting at root level, if root level element is an array. {pull}3415
- Add device support for Azure AD entity analytics. {pull}35807[35807]
- Improve CEL input performance. {pull}35915[35915]
- Adding filename details from zip to response for httpjson {issue}33952[33952] {pull}34044[34044]
- Add device handling to Okta input package for entity analytics. {pull}36049[36049]

*Auditbeat*
- Migration of system/package module storage from gob encoding to flatbuffer encoding in bolt db. {pull}34817[34817]
Expand Down
143 changes: 128 additions & 15 deletions x-pack/filebeat/docs/inputs/input-entity-analytics.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ Override the default authentication scopes. Only change if directed to do so.
[id="provider-okta"]
==== Okta User Identities (`okta`)

The `okta` provider allows the input to retrieve users from the Okta user
API.
The `okta` provider allows the input to retrieve users and devices from the
Okta user API.

[float]
==== Setup
Expand All @@ -302,23 +302,25 @@ via the `okta_token` configuration field.
===== Overview

The Okta provider periodically contacts the Okta API, retrieving updates for
users, updates its internal cache of user metadata, and ships updated user
metadata to Elasticsearch.
users and devices, updates its internal cache of user metadata, and ships
updated user metadata to Elasticsearch.

Fetching and shipping updates occurs in one of two processes: **full
synchronizations** and *incremental updates*. Full synchronizations will send the
entire list of users in state, along with write markers to indicate the start
and end of the synchronization event. Incremental updates will only send data
for changed users during that event. Changes on a user can come in many forms,
whether it be a change to the user's metadata, or a user was added or deleted.
synchronizations** and *incremental updates*. Full synchronizations will send
the entire list of users and devices in state, along with write markers to
indicate the start and end of the synchronization event. Incremental updates
will only send data for changed users and devices during that event. Changes
on a user or device can come in many forms, whether it be a change to the
user's metadata, or a user was added or deleted.

[float]
===== API Interactions

The provider periodically retrieves changes to user metadata from the
Okta User API. This is done through calls to:
The provider periodically retrieves changes to user/device metadata from the
Okta User and Device APIs. This is done through calls to:

- https://developer.okta.com/docs/reference/api/users/#list-users[/api/v1/users]
- https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Device/#tag/Device/operation/listDevices[/api/v1/devices]

Updates are tracked by the provider by retaining a record of the time of the last
noted update in the returned user list. During provider updates the Okta provider
Expand All @@ -328,10 +330,10 @@ since the provider's recorded last update.
[float]
===== Sending User Metadata to Elasticsearch

During a full synchronization, all users stored in state will be sent to the
output, while incremental updates will only send users which have been updated.
Full synchronizations will be bounded on either side by write marker documents,
which will look something like this:
During a full synchronization, all users/devices stored in state will be sent
to the output, while incremental updates will only send users and devices
that have been updated. Full synchronizations will be bounded on either side
by write marker documents, which will look something like this:

["source","json",subs="attributes"]
----
Expand Down Expand Up @@ -398,6 +400,110 @@ Example user document:
}
----

Device documents will show the current state of the device, including any
associated users.

Example device document:

["source","json",subs="attributes"]
----
{
"@timestamp": "2023-07-04T09:57:19.786056-05:00",
"event": {
"action": "device-discovered",
},
"okta": {
"created": "2019-10-02T18:03:07Z",
"id": "deviceid",
"lastUpdated": "2019-10-02T18:03:07Z",
"profile": {
"diskEncryptionType": "ALL_INTERNAL_VOLUMES",
"displayName": "Example Device name 1",
"platform": "WINDOWS",
"registered": true,
"secureHardwarePresent": false,
"serialNumber": "XXDDRFCFRGF3M8MD6D",
"sid": "S-1-11-111"
},
"resourceAlternateID": "",
"resourceDisplayName": {
"sensitive": false,
"value": "Example Device name 1"
},
"resourceID": "deviceid",
"resourceType": "UDDevice",
"status": "ACTIVE",
"_links": {
"activate": {
"hints": {
"allow": [
"POST"
]
},
"href": "https://localhost/api/v1/devices/deviceid/lifecycle/activate"
},
"self": {
"hints": {
"allow": [
"GET",
"PATCH",
"PUT"
]
},
"href": "https://localhost/api/v1/devices/deviceid"
},
"users": {
"hints": {
"allow": [
"GET"
]
},
"href": "https://localhost/api/v1/devices/deviceid/users"
}
},
"users": [
{
"id": "userid",
"status": "RECOVERY",
"created": "2023-05-14T13:37:20Z",
"activated": "0001-01-01T00:00:00Z",
"statusChanged": "2023-05-15T01:50:30Z",
"lastLogin": "2023-05-15T01:59:20Z",
"lastUpdated": "2023-05-15T01:50:32Z",
"passwordChanged": "2023-05-15T01:50:32Z",
"type": {
"id": "typeid"
},
"profile": {
"login": "[email protected]",
"email": "[email protected]",
"firstName": "name",
"lastName": "surname"
},
"credentials": {
"password": {},
"provider": {
"type": "OKTA",
"name": "OKTA"
}
},
"_links": {
"self": {
"href": "https://localhost/api/v1/users/userid"
}
}
}
]
},
"device": {
"id": "deviceid",
},
"labels": {
"identity_source": "okta-1"
}
}
----

[float]
==== Configuration

Expand Down Expand Up @@ -428,6 +534,13 @@ The Okta domain. Field is required.

The Okta secret token, used for authentication. Field is required.

[float]
===== `collect_device_details`

Whether the input should collect device and device-associated user details
from the Okta API. Device details must be activated on the Okta account for
this option.

[float]
===== `sync_interval`

Expand Down
5 changes: 5 additions & 0 deletions x-pack/filebeat/input/entityanalytics/provider/okta/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type conf struct {
OktaDomain string `config:"okta_domain" validate:"required"`
OktaToken string `config:"okta_token" validate:"required"`

// WantDevices indicates that device details
// should be collected. This is optional as
// the devices API is not necessarily activated.
WantDevices bool `config:"collect_device_details"`

// SyncInterval is the time between full
// synchronisation operations.
SyncInterval time.Duration `config:"sync_interval"`
Expand Down
Loading

0 comments on commit 5d58d30

Please sign in to comment.