Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Okta+AWS v2 #47

Merged
merged 7 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cmd/baton-okta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ var (
ciam = field.BoolField("ciam", field.WithDescription("Whether to run in CIAM mode or not. In CIAM mode, only roles and the users assigned to roles are synced"))
ciamEmailDomains = field.StringSliceField("ciam-email-domains",
field.WithDescription("The email domains to use for CIAM mode. Any users that don't have an email address with one of the provided domains will be ignored, unless explicitly granted a role"))
cache = field.BoolField("cache", field.WithDescription("Enable response cache"), field.WithDefaultValue(true))
cacheTTI = field.IntField("cache-tti", field.WithDescription("Response cache cleanup interval in seconds"), field.WithDefaultValue(60))
cacheTTL = field.IntField("cache-ttl", field.WithDescription("Response cache time to live in seconds"), field.WithDefaultValue(300))
cache = field.BoolField("cache", field.WithDescription("Enable response cache"), field.WithDefaultValue(true))
cacheTTI = field.IntField("cache-tti", field.WithDescription("Response cache cleanup interval in seconds"), field.WithDefaultValue(60))
cacheTTL = field.IntField("cache-ttl", field.WithDescription("Response cache time to live in seconds"), field.WithDefaultValue(300))
awsIdentityCenterMode = field.BoolField("aws-identity-center-mode",
field.WithDescription("Whether to run in AWS Identity center mode or not. In AWS mode, only samlRoles for groups and the users assigned to groups are synced"))
awsOktaAppId = field.StringField("aws-okta-app-id", field.WithDescription("The Okta app id for the AWS application"))
)

var relationships = []field.SchemaFieldRelationship{
field.FieldsDependentOn([]field.SchemaField{oktaPrivateKeyId, oktaPrivateKey}, []field.SchemaField{oktaClientId}),
field.FieldsDependentOn([]field.SchemaField{awsOktaAppId}, []field.SchemaField{awsIdentityCenterMode}),
field.FieldsMutuallyExclusive(apiToken, oktaClientId),
field.FieldsAtLeastOneUsed(apiToken, oktaClientId),
field.FieldsMutuallyExclusive(ciam, awsIdentityCenterMode),
field.FieldsRequiredTogether(awsIdentityCenterMode, awsOktaAppId),
}

var configuration = field.NewConfiguration([]field.SchemaField{
Expand All @@ -39,4 +45,6 @@ var configuration = field.NewConfiguration([]field.SchemaField{
cache,
cacheTTI,
cacheTTL,
awsIdentityCenterMode,
awsOktaAppId,
}, relationships...)
2 changes: 2 additions & 0 deletions cmd/baton-okta/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, e
Cache: v.GetBool("cache"),
CacheTTI: v.GetInt32("cache-tti"),
CacheTTL: v.GetInt32("cache-ttl"),
AWSMode: v.GetBool("aws-identity-center-mode"),
AWSOktaAppId: v.GetString("aws-okta-app-id"),
}

cb, err := connector.New(ctx, ccfg)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.2

require (
github.com/conductorone/baton-sdk v0.2.25
github.com/deckarep/golang-set/v2 v2.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/okta/okta-sdk-golang/v2 v2.20.0
github.com/spf13/viper v1.19.0
Expand Down Expand Up @@ -37,7 +38,6 @@ require (
github.com/aws/smithy-go v1.20.2 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/doug-martin/goqu/v9 v9.19.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
Expand Down
13 changes: 13 additions & 0 deletions pkg/connector/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@ func oktaAppsToOktaApplications(ctx context.Context, apps []okta.App) ([]*okta.A
return applications, nil
}

func oktaAppToOktaApplication(ctx context.Context, app okta.App) (*okta.Application, error) {
var oktaApp okta.Application
b, err := json.Marshal(app)
if err != nil {
return nil, fmt.Errorf("okta-connectorv2: error marshalling okta app: %w", err)
}
err = json.Unmarshal(b, &oktaApp)
if err != nil {
return nil, fmt.Errorf("okta-connectorv2: error unmarshalling okta app: %w", err)
}
return &oktaApp, nil
}

func appResource(ctx context.Context, app *okta.Application) (*v2.Resource, error) {
appProfile := map[string]interface{}{
"status": app.Status,
Expand Down
Loading
Loading