OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package storage
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"crypto"
|
|
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewCustomHealthCheckFunc returns a new health check function.
|
|
|
|
|
func NewCustomHealthCheckFunc(s Storage, now func() time.Time) func(context.Context) (details interface{}, err error) {
|
|
|
|
|
return func(_ context.Context) (details interface{}, err error) {
|
|
|
|
|
a := AuthRequest{
|
|
|
|
|
ID: NewID(),
|
|
|
|
|
ClientID: NewID(),
|
|
|
|
|
|
|
|
|
|
// Set a short expiry so if the delete fails this will be cleaned up quickly by garbage collection.
|
|
|
|
|
Expiry: now().Add(time.Minute),
|
|
|
|
|
HMACKey: NewHMACKey(crypto.SHA256),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := s.CreateAuthRequest(a); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("create auth request: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := s.DeleteAuthRequest(a.ID); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("delete auth request: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
}
|