2 configurations for the listeners are now possible: - enableJWT=false with client ssl auth - enableJWT=true with https Actual verification of the tokens is handled by https://github.com/openshift-online/ocm-sdk-go. An authentication handler is run as the top level handler, before any routing is done. Routes which do not require authentication should be listed as exceptions. Authentication can be restricted using an ACL file which allows filtering based on JWT claims. For more information see the inline comments in ocm-sdk/authentication. As an added quirk the `-v` flag for the osbuild-composer executable was changed to `-verbose` to avoid flag collision with glog which declares the `-v` flag in the package `init()` function. The ocm-sdk depends on glog and pulls it in.
66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package backoff
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// BackOffContext is a backoff policy that stops retrying after the context
|
|
// is canceled.
|
|
type BackOffContext interface { // nolint: golint
|
|
BackOff
|
|
Context() context.Context
|
|
}
|
|
|
|
type backOffContext struct {
|
|
BackOff
|
|
ctx context.Context
|
|
}
|
|
|
|
// WithContext returns a BackOffContext with context ctx
|
|
//
|
|
// ctx must not be nil
|
|
func WithContext(b BackOff, ctx context.Context) BackOffContext { // nolint: golint
|
|
if ctx == nil {
|
|
panic("nil context")
|
|
}
|
|
|
|
if b, ok := b.(*backOffContext); ok {
|
|
return &backOffContext{
|
|
BackOff: b.BackOff,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
return &backOffContext{
|
|
BackOff: b,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
func getContext(b BackOff) context.Context {
|
|
if cb, ok := b.(BackOffContext); ok {
|
|
return cb.Context()
|
|
}
|
|
if tb, ok := b.(*backOffTries); ok {
|
|
return getContext(tb.delegate)
|
|
}
|
|
return context.Background()
|
|
}
|
|
|
|
func (b *backOffContext) Context() context.Context {
|
|
return b.ctx
|
|
}
|
|
|
|
func (b *backOffContext) NextBackOff() time.Duration {
|
|
select {
|
|
case <-b.ctx.Done():
|
|
return Stop
|
|
default:
|
|
}
|
|
next := b.BackOff.NextBackOff()
|
|
if deadline, ok := b.ctx.Deadline(); ok && deadline.Sub(time.Now()) < next { // nolint: gosimple
|
|
return Stop
|
|
}
|
|
return next
|
|
}
|