Skip to content

Commit

Permalink
feat: V2 authn config + redis (#3852)
Browse files Browse the repository at this point in the history
* feat: auth refactor and redis store impl

Signed-off-by: Mark Phelps <[email protected]>

* chore: remove auth cleanup config for now

Signed-off-by: Mark Phelps <[email protected]>

* chore: rm cleanup

Signed-off-by: Mark Phelps <[email protected]>

* chore: refactor

Signed-off-by: Mark Phelps <[email protected]>

* chore: support ordering

Signed-off-by: Mark Phelps <[email protected]>

* Revert "chore: support ordering"

This reverts commit db5f0d4.

* chore: add back some listing test

Signed-off-by: Mark Phelps <[email protected]>

* chore: fix tests

Signed-off-by: Mark Phelps <[email protected]>

* chore: make generator funcs testable

Signed-off-by: Mark Phelps <[email protected]>

* chore: rename redis store test

Signed-off-by: Mark Phelps <[email protected]>

* chore: use existing constants and helpers for keys

Signed-off-by: Mark Phelps <[email protected]>

* chore: support graceperiod for token expiry and add cleanup for memory store

Signed-off-by: Mark Phelps <[email protected]>

* chore: add back cleanup graceperiod to schemas

Signed-off-by: Mark Phelps <[email protected]>

* chore: fix test compilation

Signed-off-by: Mark Phelps <[email protected]>

* chore: mod tidy

Signed-off-by: Mark Phelps <[email protected]>

---------

Signed-off-by: Mark Phelps <[email protected]>
  • Loading branch information
markphelps authored Jan 28, 2025
1 parent afd9531 commit 9ebc0a1
Show file tree
Hide file tree
Showing 43 changed files with 1,090 additions and 1,083 deletions.
222 changes: 0 additions & 222 deletions cmd/flipt/evaluate.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/flipt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func exec() error {
rootCmd.AddCommand(newConfigCommand())
rootCmd.AddCommand(newCompletionCommand())
rootCmd.AddCommand(newDocCommand())
rootCmd.AddCommand(newEvaluateCommand())

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
17 changes: 8 additions & 9 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ import "list"

storage?: *{
type: "memory"
cleanup?: #authentication.#storage_cleanup
cleanup?: {
grace_period?: =~#duration | int | *"30m"
}
} | {
type: "redis"
cleanup?: #authentication.#storage_cleanup
connection: {
redis?: {
host?: string | *"localhost"
port?: int | *6379
require_tls?: bool | *false
Expand All @@ -65,15 +66,13 @@ import "list"
ca_cert_bytes?: string
insecure_skip_tls?: bool | *false
}
}

#storage_cleanup: {
@jsonschema(id="storage_cleanup")
interval?: =~#duration | int | *"1h"
grace_period?: =~#duration | int | *"30m"
cleanup?: {
grace_period?: =~#duration | int | *"30m"
}
}
}


methods?: {
token?: {
enabled?: bool | *false
Expand Down
49 changes: 17 additions & 32 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@
"enum": ["memory"]
},
"cleanup": {
"$ref": "#/definitions/storage_cleanup"
"type": "object",
"properties": {
"grace_period": {
"type": "string",
"default": "30m",
"pattern": "^([0-9]+(ns|us|µs|ms|s|m|h))+$"
}
}
}
},
"additionalProperties": false
Expand All @@ -164,9 +171,16 @@
"enum": ["redis"]
},
"cleanup": {
"$ref": "#/definitions/storage_cleanup"
"type": "object",
"properties": {
"grace_period": {
"type": "string",
"default": "30m",
"pattern": "^([0-9]+(ns|us|µs|ms|s|m|h))+$"
}
}
},
"connection": {
"redis": {
"type": "object",
"properties": {
"host": {
Expand Down Expand Up @@ -996,35 +1010,6 @@
}
},
"definitions": {
"storage_cleanup": {
"type": "object",
"properties": {
"interval": {
"oneOf": [
{
"type": "string",
"pattern": "^([0-9]+(ns|us|µs|ms|s|m|h))+$"
},
{
"type": "integer"
}
],
"default": "1h"
},
"grace_period": {
"oneOf": [
{
"type": "string",
"pattern": "^([0-9]+(ns|us|µs|ms|s|m|h))+$"
},
{
"type": "integer"
}
],
"default": "30m"
}
}
},
"authentication_oidc_provider": {
"type": "object",
"properties": {
Expand Down
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
github.com/open-policy-agent/opa v0.70.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.62.0
github.com/redis/go-redis/v9 v9.7.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -71,8 +72,7 @@ require (
go.opentelemetry.io/otel/trace v1.34.0
go.uber.org/zap v1.27.0
gocloud.dev v0.40.0
golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
golang.org/x/net v0.34.0
golang.org/x/oauth2 v0.25.0
golang.org/x/sync v0.10.0
Expand Down Expand Up @@ -143,9 +143,11 @@ require (
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/creack/pty v1.1.20 // indirect
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand Down Expand Up @@ -193,7 +195,7 @@ require (
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
Expand Down Expand Up @@ -223,7 +225,6 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/redis/go-redis/v9 v9.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand Down Expand Up @@ -260,6 +261,7 @@ require (
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
Expand Down
Loading

0 comments on commit 9ebc0a1

Please sign in to comment.