feat: support to ory hydra running in secure mode (#62)

This commit is contained in:
fjvierap
2021-05-10 11:18:39 +02:00
committed by GitHub
parent 9d56503601
commit 0ac577939c
9 changed files with 273 additions and 61 deletions

View File

@ -37,8 +37,6 @@ const (
FinalizerName = "finalizer.ory.hydra.sh"
)
type HydraClientMakerFunc func(hydrav1alpha1.OAuth2ClientSpec) (HydraClientInterface, error)
type clientMapKey struct {
url string
port int
@ -56,10 +54,9 @@ type HydraClientInterface interface {
// OAuth2ClientReconciler reconciles a OAuth2Client object
type OAuth2ClientReconciler struct {
HydraClient HydraClientInterface
HydraClientMaker HydraClientMakerFunc
Log logr.Logger
otherClients map[clientMapKey]HydraClientInterface
HydraClient HydraClientInterface
Log logr.Logger
otherClients map[clientMapKey]HydraClientInterface
client.Client
}
@ -332,10 +329,6 @@ func parseSecret(secret apiv1.Secret, authMethod hydrav1alpha1.TokenEndpointAuth
func (r *OAuth2ClientReconciler) getHydraClientForClient(oauth2client hydrav1alpha1.OAuth2Client) (HydraClientInterface, error) {
spec := oauth2client.Spec
if spec.HydraAdmin == (hydrav1alpha1.HydraAdmin{}) {
r.Log.Info(fmt.Sprintf("using default client"))
return r.HydraClient, nil
}
key := clientMapKey{
url: spec.HydraAdmin.URL,
port: spec.HydraAdmin.Port,
@ -345,7 +338,12 @@ func (r *OAuth2ClientReconciler) getHydraClientForClient(oauth2client hydrav1alp
if c, ok := r.otherClients[key]; ok {
return c, nil
}
return r.HydraClientMaker(spec)
if r.HydraClient == nil {
return nil, errors.New("Not default client or other clients configured")
}
r.Log.Info(fmt.Sprintf("using default client"))
return r.HydraClient, nil
}
// Helper functions to check and remove string from a slice of strings.

View File

@ -465,9 +465,6 @@ func getAPIReconciler(mgr ctrl.Manager, mock controllers.HydraClientInterface) r
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("OAuth2Client"),
HydraClient: mock,
HydraClientMaker: func(hydrav1alpha1.OAuth2ClientSpec) (controllers.HydraClientInterface, error) {
return mock, nil
},
}
}