mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
fix lint
This commit is contained in:
parent
bee64a21b8
commit
f9def98eb1
17 changed files with 56 additions and 53 deletions
|
@ -4,6 +4,6 @@ package opa
|
||||||
|
|
||||||
import _ "embed" // to embed files
|
import _ "embed" // to embed files
|
||||||
|
|
||||||
// HeadersRego is the headers.rego script.
|
|
||||||
//go:embed policy/headers.rego
|
//go:embed policy/headers.rego
|
||||||
|
// HeadersRego is the headers.rego script.
|
||||||
var HeadersRego string
|
var HeadersRego string
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains pomerium.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains the pomerium-integration-tests command.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -78,12 +79,12 @@ func runGenerateConfiguration(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
asYAML, _ := yaml.JSONToYAML([]byte(contents))
|
asYAML, _ := yaml.JSONToYAML([]byte(contents))
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Dir(dstPath), 0755)
|
err = os.MkdirAll(filepath.Dir(dstPath), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err)
|
return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(dstPath, asYAML, 0600)
|
err = os.WriteFile(dstPath, asYAML, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error writing file (path=%s): %w", dstPath, err)
|
return fmt.Errorf("error writing file (path=%s): %w", dstPath, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains integration tests.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -51,10 +51,10 @@ func newDeltaCollection(p *Provider) *deltaCollection {
|
||||||
//
|
//
|
||||||
// It involves 4 steps:
|
// It involves 4 steps:
|
||||||
//
|
//
|
||||||
// 1. an initial request to /v1.0/groups/delta
|
// 1. an initial request to /v1.0/groups/delta
|
||||||
// 2. one or more requests to /v1.0/groups/delta?$skiptoken=..., which comes from the @odata.nextLink
|
// 2. one or more requests to /v1.0/groups/delta?$skiptoken=..., which comes from the @odata.nextLink
|
||||||
// 3. a final response with @odata.deltaLink
|
// 3. a final response with @odata.deltaLink
|
||||||
// 4. on the next call to sync, starting at @odata.deltaLink
|
// 4. on the next call to sync, starting at @odata.deltaLink
|
||||||
//
|
//
|
||||||
// Only the changed groups/members are returned. Removed groups/members have an @removed property.
|
// Only the changed groups/members are returned. Removed groups/members have an @removed property.
|
||||||
func (dc *deltaCollection) Sync(ctx context.Context) error {
|
func (dc *deltaCollection) Sync(ctx context.Context) error {
|
||||||
|
|
|
@ -65,8 +65,7 @@ func (claims Claims) Claims(v interface{}) error {
|
||||||
|
|
||||||
// Flatten flattens the claims to a FlattenedClaims map. For example:
|
// Flatten flattens the claims to a FlattenedClaims map. For example:
|
||||||
//
|
//
|
||||||
// { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] }
|
// { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] }
|
||||||
//
|
|
||||||
func (claims Claims) Flatten() FlattenedClaims {
|
func (claims Claims) Flatten() FlattenedClaims {
|
||||||
flattened := make(FlattenedClaims)
|
flattened := make(FlattenedClaims)
|
||||||
for k, v := range claims {
|
for k, v := range claims {
|
||||||
|
|
|
@ -29,8 +29,8 @@ var defaultScopes = []string{oidc.ScopeOpenID, "profile", "email"}
|
||||||
// having the user select which Google account they'd like to use.
|
// having the user select which Google account they'd like to use.
|
||||||
//
|
//
|
||||||
// For more details, please see google's documentation:
|
// For more details, please see google's documentation:
|
||||||
// https://developers.google.com/identity/protocols/oauth2/web-server#offline
|
// https://developers.google.com/identity/protocols/oauth2/web-server#offline
|
||||||
// https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters
|
// https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters
|
||||||
var defaultAuthCodeOptions = map[string]string{"prompt": "select_account consent", "access_type": "offline"}
|
var defaultAuthCodeOptions = map[string]string{"prompt": "select_account consent", "access_type": "offline"}
|
||||||
|
|
||||||
// Provider is a Google implementation of the Authenticator interface.
|
// Provider is a Google implementation of the Authenticator interface.
|
||||||
|
|
|
@ -100,27 +100,26 @@ func NewClientFromURL(rawURL string, tlsConfig *tls.Config) (redis.UniversalClie
|
||||||
|
|
||||||
// ParseClusterURL parses a redis-cluster URL. Format is:
|
// ParseClusterURL parses a redis-cluster URL. Format is:
|
||||||
//
|
//
|
||||||
// redis+cluster://[username:password@]host:port[,host2:port2,...]/[?param1=value1[¶m2=value=2&...]]
|
// redis+cluster://[username:password@]host:port[,host2:port2,...]/[?param1=value1[¶m2=value=2&...]]
|
||||||
//
|
//
|
||||||
// Additionally TLS is supported with rediss+cluster, or redis+clusters. Supported query params:
|
// Additionally TLS is supported with rediss+cluster, or redis+clusters. Supported query params:
|
||||||
//
|
//
|
||||||
// max_redirects: int
|
// max_redirects: int
|
||||||
// read_only: bool
|
// read_only: bool
|
||||||
// route_by_latency: bool
|
// route_by_latency: bool
|
||||||
// route_randomly: bool
|
// route_randomly: bool
|
||||||
// max_retries: int
|
// max_retries: int
|
||||||
// min_retry_backoff: duration
|
// min_retry_backoff: duration
|
||||||
// max_retry_backoff: duration
|
// max_retry_backoff: duration
|
||||||
// dial_timeout: duration
|
// dial_timeout: duration
|
||||||
// read_timeout: duration
|
// read_timeout: duration
|
||||||
// write_timeout: duration
|
// write_timeout: duration
|
||||||
// pool_size: int
|
// pool_size: int
|
||||||
// min_idle_conns: int
|
// min_idle_conns: int
|
||||||
// max_conn_age: duration
|
// max_conn_age: duration
|
||||||
// pool_timeout: duration
|
// pool_timeout: duration
|
||||||
// idle_timeout: duration
|
// idle_timeout: duration
|
||||||
// idle_check_frequency: duration
|
// idle_check_frequency: duration
|
||||||
//
|
|
||||||
func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) {
|
func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) {
|
||||||
u, err := url.Parse(rawurl)
|
u, err := url.Parse(rawurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains main.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -189,7 +190,8 @@ func saveConfig(ctx context.Context, client databroker.DataBrokerServiceClient,
|
||||||
Type: any.GetTypeUrl(),
|
Type: any.GetTypeUrl(),
|
||||||
Id: "test_config",
|
Id: "test_config",
|
||||||
Data: any,
|
Data: any,
|
||||||
}}})
|
}},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,17 @@ func NewChain(constructors ...Constructor) Chain {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then chains the trippers and returns the final http.RoundTripper.
|
// Then chains the trippers and returns the final http.RoundTripper.
|
||||||
// NewChain(m1, m2, m3).Then(h)
|
// NewChain(m1, m2, m3).Then(h)
|
||||||
// is equivalent to:
|
// is equivalent to:
|
||||||
// m1(m2(m3(h)))
|
// m1(m2(m3(h)))
|
||||||
// When the request comes in, it will be passed to m1, then m2, then m3
|
// When the request comes in, it will be passed to m1, then m2, then m3
|
||||||
// and finally, the given roundtripper
|
// and finally, the given roundtripper
|
||||||
// (assuming every tripper calls the following one).
|
// (assuming every tripper calls the following one).
|
||||||
//
|
//
|
||||||
// A chain can be safely reused by calling Then() several times.
|
// A chain can be safely reused by calling Then() several times.
|
||||||
// stdStack := tripper.NewChain(ratelimitTripper, csrfTripper)
|
// stdStack := tripper.NewChain(ratelimitTripper, csrfTripper)
|
||||||
// tracePipe = stdStack.Then(traceTripper)
|
// tracePipe = stdStack.Then(traceTripper)
|
||||||
// authPipe = stdStack.Then(authTripper)
|
// authPipe = stdStack.Then(authTripper)
|
||||||
// Note that constructors are called on every call to Then()
|
// Note that constructors are called on every call to Then()
|
||||||
// and thus several instances of the same tripper will be created
|
// and thus several instances of the same tripper will be created
|
||||||
// when a chain is reused in this way.
|
// when a chain is reused in this way.
|
||||||
|
|
|
@ -22,8 +22,7 @@ type SignedURL struct {
|
||||||
|
|
||||||
// NewSignedURL creates a new copy of a URL that can be signed with a shared key.
|
// NewSignedURL creates a new copy of a URL that can be signed with a shared key.
|
||||||
//
|
//
|
||||||
// N.B. It is the user's responsibility to make sure the key is 256 bits and
|
// N.B. It is the user's responsibility to make sure the key is 256 bits and the url is not nil.
|
||||||
// the url is not nil.
|
|
||||||
func NewSignedURL(key []byte, uri *url.URL) *SignedURL {
|
func NewSignedURL(key []byte, uri *url.URL) *SignedURL {
|
||||||
return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied
|
return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Package pomerium houses the main pomerium CLI command.
|
// Package pomerium houses the main pomerium CLI command.
|
||||||
//
|
|
||||||
package pomerium
|
package pomerium
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -9,12 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMerge(t *testing.T) {
|
func TestMerge(t *testing.T) {
|
||||||
|
type key1 struct{}
|
||||||
|
type key2 struct{}
|
||||||
|
|
||||||
t.Run("value", func(t *testing.T) {
|
t.Run("value", func(t *testing.T) {
|
||||||
ctx1 := context.WithValue(context.Background(), "key1", "value1")
|
ctx1 := context.WithValue(context.Background(), key1{}, "value1")
|
||||||
ctx2 := context.WithValue(context.Background(), "key2", "value2")
|
ctx2 := context.WithValue(context.Background(), key2{}, "value2")
|
||||||
ctx3, _ := Merge(ctx1, ctx2)
|
ctx3, _ := Merge(ctx1, ctx2)
|
||||||
assert.Equal(t, "value1", ctx3.Value("key1"))
|
assert.Equal(t, "value1", ctx3.Value(key1{}))
|
||||||
assert.Equal(t, "value2", ctx3.Value("key2"))
|
assert.Equal(t, "value2", ctx3.Value(key2{}))
|
||||||
})
|
})
|
||||||
t.Run("cancel", func(t *testing.T) {
|
t.Run("cancel", func(t *testing.T) {
|
||||||
ctx1, cancel1 := context.WithCancel(context.Background())
|
ctx1, cancel1 := context.WithCancel(context.Background())
|
||||||
|
|
|
@ -10,9 +10,10 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A keypair for NIST P-256 / secp256r1
|
// A keypair for NIST P-256 / secp256r1.
|
||||||
|
//
|
||||||
// Generated using:
|
// Generated using:
|
||||||
// openssl ecparam -genkey -name prime256v1 -outform PEM
|
// openssl ecparam -genkey -name prime256v1 -outform PEM
|
||||||
var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS-----
|
var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS-----
|
||||||
BggqhkjOPQMBBw==
|
BggqhkjOPQMBBw==
|
||||||
-----END EC PARAMETERS-----
|
-----END EC PARAMETERS-----
|
||||||
|
|
|
@ -13,18 +13,17 @@ import (
|
||||||
// A KeyEncryptionKey (KEK) is used to implement *envelope encryption*, similar to how data is stored at rest with
|
// A KeyEncryptionKey (KEK) is used to implement *envelope encryption*, similar to how data is stored at rest with
|
||||||
// AWS or Google Cloud:
|
// AWS or Google Cloud:
|
||||||
//
|
//
|
||||||
// - AWS: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping
|
// - AWS: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping
|
||||||
// - Google Cloud: https://cloud.google.com/kms/docs/envelope-encryption
|
// - Google Cloud: https://cloud.google.com/kms/docs/envelope-encryption
|
||||||
//
|
//
|
||||||
// Data is encrypted with a data encryption key (DEK) and that key is stored next to the data encrypted with the KEK.
|
// Data is encrypted with a data encryption key (DEK) and that key is stored next to the data encrypted with the KEK.
|
||||||
// Finally the KEK id is also stored with the data.
|
// Finally the KEK id is also stored with the data.
|
||||||
//
|
//
|
||||||
// To decrypt the data you first retrieve the KEK, second decrypt the DEK, and finally decrypt the data using the DEK.
|
// To decrypt the data you first retrieve the KEK, second decrypt the DEK, and finally decrypt the data using the DEK.
|
||||||
//
|
//
|
||||||
// - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can
|
// - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can
|
||||||
// decrypt it.
|
// decrypt it.
|
||||||
// - Our DEKs are symmetric XChaCha20Poly1305 keys.
|
// - Our DEKs are symmetric XChaCha20Poly1305 keys.
|
||||||
//
|
|
||||||
type KeyEncryptionKey interface {
|
type KeyEncryptionKey interface {
|
||||||
ID() string
|
ID() string
|
||||||
KeyBytes() []byte
|
KeyBytes() []byte
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// generated using:
|
// generated using:
|
||||||
// openssl genpkey -algorithm x25519 -out priv.pem
|
// openssl genpkey -algorithm x25519 -out priv.pem
|
||||||
// openssl pkey -in priv.pem -out pub.pem -pubout
|
// openssl pkey -in priv.pem -out pub.pem -pubout
|
||||||
var (
|
var (
|
||||||
rawPrivateX25519Key = []byte(`-----BEGIN PRIVATE KEY-----
|
rawPrivateX25519Key = []byte(`-----BEGIN PRIVATE KEY-----
|
||||||
MC4CAQAwBQYDK2VuBCIEIKALoNgzCksH0v0Bc7Ghl8vGin4MAIKpmtZSmaMN0Vtb
|
MC4CAQAwBQYDK2VuBCIEIKALoNgzCksH0v0Bc7Ghl8vGin4MAIKpmtZSmaMN0Vtb
|
||||||
|
|
|
@ -59,7 +59,6 @@ func NewLeasers(leaseName string, ttl time.Duration, client DataBrokerServiceCli
|
||||||
//
|
//
|
||||||
// 1. ctx is canceled
|
// 1. ctx is canceled
|
||||||
// 2. a non-cancel error is returned from handler
|
// 2. a non-cancel error is returned from handler
|
||||||
//
|
|
||||||
func (locker *Leaser) Run(ctx context.Context) error {
|
func (locker *Leaser) Run(ctx context.Context) error {
|
||||||
retryTicker := time.NewTicker(locker.ttl / 2)
|
retryTicker := time.NewTicker(locker.ttl / 2)
|
||||||
defer retryTicker.Stop()
|
defer retryTicker.Stop()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue