Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Add support for Okta
Browse files Browse the repository at this point in the history
Accepts token through a command line argument.
Add a new sync only for Okta.
  • Loading branch information
vrajat committed Nov 10, 2023
1 parent 022e52f commit 0a3d816
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cartography/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ def _build_parser(self):
'Okta organizational id to sync. Required if you are using the Okta intel module. Ignored otherwise.'
),
)
parser.add_argument(
'--okta-api-key',
type=str,
default=None,
help=(
'Key with which to auth to the Okta API.'
),
)
parser.add_argument(
'--okta-api-key-env-var',
type=str,
Expand Down Expand Up @@ -513,12 +521,7 @@ def main(self, argv: str) -> int:
else:
config.azure_client_secret = None

# Okta config
if config.okta_org_id and config.okta_api_key_env_var:
logger.debug(f"Reading API key for Okta from environment variable {config.okta_api_key_env_var}")
config.okta_api_key = os.environ.get(config.okta_api_key_env_var)
else:
config.okta_api_key = None
# Okta config. Rajat: No extra work required any more.

# CRXcavator config
if config.crxcavator_api_base_uri and config.crxcavator_api_key_env_var:
Expand Down Expand Up @@ -622,8 +625,10 @@ def main(argv=None, sync_flag=None):
if(requested_sync == 'rule_check'):
sync = cartography.sync.build_rule_check_sync()
result = CLI(sync, prog='cartography').main(argv)
if(requested_sync.startswith("gcp")):
elif(requested_sync.startswith("gcp")):
sync = cartography.sync.build_borneo_gcp_sync("skip_index" in requested_sync)
elif(requested_sync.startswith("okta")):
sync = cartography.sync.build_borneo_okta_sync("skip_index" in requested_sync)
result = CLI(sync, prog='cartography').main(argv)
else:
if(requested_sync != "default"):
Expand Down
9 changes: 9 additions & 0 deletions cartography/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ def build_borneo_gcp_sync(skipIndex: bool) -> Sync:
])
return sync

def build_borneo_okta_sync(skipIndex: bool) -> Sync:
sync = Sync()
if skipIndex != True:
sync.add_stages([('create-indexes', cartography.intel.create_indexes.run)])
sync.add_stages([
('okta', cartography.intel.okta.start_okta_ingestion),
])
return sync

def build_rule_check_sync() -> Sync:
sync = Sync()
sync.add_stages([
Expand Down

0 comments on commit 0a3d816

Please sign in to comment.