GithubHelp home page GithubHelp logo

gov-okta-addon's Introduction

gov-okta-addon

gov-okta-addon is an addon to integrate Okta with Governor.

Usage

Updates to Okta are triggered both by a reconciliation loop as well as change events from Governor. During time based reconciliation, gov-okta-addon requests all of the groups from Governor and ensures those groups exist in Okta and are configured with the same Github organizations. Group membership is also reconciled, ensuring that all group members of managed groups in Governor are also members of the group in Okta. Users are reconciled by making sure deleted users in Governor and deleted in Okta (currently this is only logging), and the status of suspended/unsuspended users is updated accordingly in Okta.

gov-okta-addon subscribes to the Governor event stream where change events are published. The events published by Governor contain the group and/or user id that changed and the type of action. Events are published on NATS subjects dedicated to the resource type ie. governor.events.groups for group events. When gov-okta-addon receives an event, it reacts by requesting information from Governor about the included resource IDs and making the required changes in Okta.

Safe mode

There are two flags that can limit the changes that gov-okta-addon makes and just log SKIP messages instead.

--skip-delete is currently enabled by default and it will prevent the timed reconcile loop from deleting stuff in Okta (this includes removing group members, removing application group assignments, or removing users). This flag does not apply to any of the NATS events which will be processed normally.

--dry-run will prevent any changes from being made while the addon is running, including the reconcile loop and NATS events.

Syncing to governor

gov-okta-addon ships with a sync command to sync resources from Okta into governor. It has a --dry-run flag which is helpful to see what resources would be affected.

Sync users

gov-okta-addon sync users will sync users from Okta to governor based on the id in their Okta profile and their external_id in Governor.

Sync groups

gov-okta-addon sync groups will sync groups from Okta to governor based on the group slug and the governor_id in their Okta profile. Groups that exist in Okta but not in governor will be created, and groups that exist in governor but not in Okta will be deleted. Optionally, you can specify --skip-okta-update to avoid making changes to the Okta group (i.e. setting the governor_id), --selector-prefix to only sync specific groups, and --skip-groups "foo,bar,baz" to skip syncing groups named foo, bar and baz.

This command will also associate any organizations with the group based on the assigned applications in Okta, but it will not sync the members of the group.

Sync group members

gov-okta-addon sync members will sync group members from Okta to governor. Group members that exist in Okta but not in governor will be added to the governor group, and governor group members that do not exist in the Okta group will be removed from the group. The groups and users must already exist in governor or they will be skipped.

Development

gov-okta-addon includes a docker-compose.yml and a Makefile to make getting started easy.

make docker-up will start a basic NATS server and gov-okta-addon.

Prereq to running locally with governor-api devcontainer

Follow the directions here for starting the governor-api devcontainer.

The first time you'll need to create a local hydra client for gov-okta-addon-governor and copy the nats creds file. After that you can just export the env variables.

NATS Creds

Run in the governor-api devcontainer:

cat /tmp/user.creds

Then create and copy into gov-okta-addon/user.local.creds

Hydra

GOA_GOVERNOR_CLIENT_SECRET="$(openssl rand -hex 16)"

hydra clients create \
    --endpoint http://hydra:4445/ \
    --audience http://api:3001/ \
    --id gov-okta-addon-governor \
    --secret ${GOA_GOVERNOR_CLIENT_SECRET} \
    --grant-types client_credentials \
    --response-types token,code \
    --token-endpoint-auth-method client_secret_post \
    --scope write,create:governor:users,update:governor:users,read:governor:users,read:governor:groups,read:governor:organizations

# Copy this secret for later
echo $GOA_GOVERNOR_CLIENT_SECRET

Env

Export the following in the terminal where you will run gov-okta-addon:

export GOA_NATS_URL="nats://127.0.0.1:4222"
export GOA_OKTA_NOCACHE=true
export GOA_OKTA_URL="https://example.oktapreview.com"
export GOA_GOVERNOR_URL="http://127.0.0.1:3001"
export GOA_GOVERNOR_AUDIENCE="http://api:3001/"
export GOA_GOVERNOR_TOKEN_URL="http://127.0.0.1:4444/oauth2/token"
export GOA_GOVERNOR_CLIENT_ID="gov-okta-addon-governor"
export GOA_NATS_CREDS_FILE="${PWD}/user.local.creds"

Similarly, ensure you have the following secrets exported:

# Get from delivery-engineering vault, check governor tag
export GOA_OKTA_TOKEN="REPLACE"
# Secret copied from earlier
export GOA_GOVERNOR_CLIENT_SECRET="REPLACE"

Troubleshooting

"error": "Unable to insert or update resource because a resource with that value exists already"

Run hydra clients delete gov-okta-addon-governor in the governor-api devcontainer. Then rerun the steps for hydra.

"error": "error", "error_description": "The error is unrecognizable"

Same as above.

Testing addon serve locally

WARNING: Be careful when running this addon locally - don't point it to the production Okta URL and and don't run it without --dry-run as it could potentially update or wipe out existing groups/users in Okta!

Create a local audit log for testing in the gov-okta-addon directory:

touch audit.log

Start the addon (adjust the flags as needed):

go run . serve --audit-log-path=audit.log --pretty --debug --dry-run

Testing addon sync locally

Run the user sync (adjust the flags as needed):

go run . sync users --pretty --debug --dry-run

You can run the groups and members sync in the same way.

gov-okta-addon's People

Contributors

fishnix avatar jacobsee avatar renovate[bot] avatar sfunkhouser avatar stephen-fox avatar sthwang-metal avatar tenyo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sfunkhouser

gov-okta-addon's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update buildkite plugin equinixmetal-buildkite/trivy to v1.18.5
  • chore(deps): update buildkite plugin docker to v5.11.0
  • fix(deps): update module github.com/gin-gonic/gin to v1.10.0
  • fix(deps): update module github.com/gosimple/slug to v1.14.0
  • fix(deps): update module github.com/metal-toolbox/governor-api to v0.2.3
  • fix(deps): update module github.com/stretchr/testify to v1.9.0
  • fix(deps): update module go.uber.org/zap to v1.27.0
  • fix(deps): update module github.com/gin-contrib/zap to v1
  • fix(deps): update module github.com/okta/okta-sdk-golang/v2 to v4
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

buildkite
.buildkite/pipeline.yml
  • docker v5.9.0
  • docker v5.9.0
  • docker v5.9.0
  • docker-login v2.1.0
  • equinixmetal-buildkite/docker-metadata v1.0.0
  • equinixmetal-buildkite/docker-build v1.1.0
  • equinixmetal-buildkite/trivy v1.18.3
docker-compose
docker-compose.yml
  • ghcr.io/metal-toolbox/audittail v0.8.0
dockerfile
Dockerfile
gomod
go.mod
  • go 1.20
  • github.com/gin-contrib/cors v1.4.0
  • github.com/gin-contrib/zap v0.2.0
  • github.com/gin-gonic/gin v1.9.1
  • github.com/gofrs/uuid v4.4.0+incompatible
  • github.com/gosimple/slug v1.13.1
  • github.com/metal-toolbox/addonx v0.1.1
  • github.com/metal-toolbox/auditevent v0.8.0
  • github.com/metal-toolbox/governor-api v0.1.7
  • github.com/mitchellh/go-homedir v1.1.0
  • github.com/nats-io/nats.go v1.30.2
  • github.com/okta/okta-sdk-golang/v2 v2.19.0
  • github.com/prometheus/client_golang v1.17.0
  • github.com/spf13/cobra v1.7.0
  • github.com/spf13/pflag v1.0.5
  • github.com/spf13/viper v1.17.0
  • github.com/stretchr/testify v1.8.4
  • github.com/volatiletech/null/v8 v8.1.2
  • github.com/zsais/go-gin-prometheus v0.1.0
  • go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.42.0
  • go.opentelemetry.io/otel v1.17.0
  • go.opentelemetry.io/otel/exporters/jaeger v1.16.0
  • go.opentelemetry.io/otel/sdk v1.17.0
  • go.uber.org/zap v1.25.0
  • golang.org/x/oauth2 v0.13.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.