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

Add response cache options to okta connector. Default to on. #41

Merged
merged 2 commits into from
Sep 3, 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
17 changes: 15 additions & 2 deletions cmd/baton-okta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ 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))
)

var relationships = []field.SchemaFieldRelationship{
Expand All @@ -24,6 +27,16 @@ var relationships = []field.SchemaFieldRelationship{
}

var configuration = field.NewConfiguration([]field.SchemaField{
domain, apiToken, oktaClientId, oktaPrivateKey, oktaPrivateKeyId,
syncInactivateApps, oktaProvisioning, ciam, ciamEmailDomains,
domain,
apiToken,
oktaClientId,
oktaPrivateKey,
oktaPrivateKeyId,
syncInactivateApps,
oktaProvisioning,
ciam,
ciamEmailDomains,
cache,
cacheTTI,
cacheTTL,
}, relationships...)
3 changes: 3 additions & 0 deletions cmd/baton-okta/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, e
OktaProvisioning: v.GetBool("okta-provisioning"),
Ciam: v.GetBool("ciam"),
CiamEmailDomains: v.GetStringSlice("ciam-email-domains"),
Cache: v.GetBool("cache"),
CacheTTI: v.GetInt32("cache-tti"),
CacheTTL: v.GetInt32("cache-ttl"),
}

cb, err := connector.New(ctx, ccfg)
Expand Down
11 changes: 9 additions & 2 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type Config struct {
OktaProvisioning bool
Ciam bool
CiamEmailDomains []string
Cache bool
CacheTTI int32
CacheTTL int32
}

func v1AnnotationsForResourceType(resourceTypeID string, skipEntitlementsAndGrants bool) annotations.Annotations {
Expand Down Expand Up @@ -177,7 +180,9 @@ func New(ctx context.Context, cfg *Config) (*Okta, error) {
okta.WithOrgUrl(fmt.Sprintf("https://%s", cfg.Domain)),
okta.WithToken(cfg.ApiToken),
okta.WithHttpClientPtr(client),
okta.WithCache(false),
okta.WithCache(cfg.Cache),
okta.WithCacheTti(cfg.CacheTTI),
okta.WithCacheTtl(cfg.CacheTTL),
)
if err != nil {
return nil, err
Expand All @@ -195,7 +200,9 @@ func New(ctx context.Context, cfg *Config) (*Okta, error) {
okta.WithScopes(scopes),
okta.WithPrivateKey(cfg.OktaPrivateKey),
okta.WithPrivateKeyId(cfg.OktaPrivateKeyId),
okta.WithCache(false),
okta.WithCache(cfg.Cache),
okta.WithCacheTti(cfg.CacheTTI),
okta.WithCacheTtl(cfg.CacheTTL),
)
if err != nil {
return nil, err
Expand Down
Loading