Skip to content

Commit

Permalink
Tentative at dealing with no opa.External provided
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps committed Sep 4, 2024
1 parent 965ea4b commit 1c23688
Show file tree
Hide file tree
Showing 3 changed files with 313 additions and 15 deletions.
36 changes: 21 additions & 15 deletions controllers/auth_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,25 +377,31 @@ func (r *AuthConfigReconciler) translateAuthConfig(ctx context.Context, authConf
case api.OpaAuthorization:
policyName := authConfig.GetNamespace() + "/" + authConfig.GetName() + "/" + authzName
opa := authorization.Opa
externalRegistry := opa.External
secret := &v1.Secret{}
var sharedSecret string

if externalRegistry.SharedSecret != nil {
if err := r.Client.Get(ctx, types.NamespacedName{
Namespace: authConfig.Namespace,
Name: externalRegistry.SharedSecret.Name},
secret); err != nil {
return nil, err // TODO: Review this error, perhaps we don't need to return an error, just reenqueue.
var (
sharedSecret string
externalSource *authorization_evaluators.OPAExternalSource
)

if opa.External != nil {
externalRegistry := opa.External
if externalRegistry.SharedSecret != nil {
if err := r.Client.Get(ctx, types.NamespacedName{
Namespace: authConfig.Namespace,
Name: externalRegistry.SharedSecret.Name},
secret); err != nil {
return nil, err // TODO: Review this error, perhaps we don't need to return an error, just reenqueue.
}
sharedSecret = string(secret.Data[externalRegistry.SharedSecret.Key])
}
sharedSecret = string(secret.Data[externalRegistry.SharedSecret.Key])
}

externalSource := &authorization_evaluators.OPAExternalSource{
Endpoint: externalRegistry.Url,
SharedSecret: sharedSecret,
AuthCredentials: newAuthCredential(externalRegistry.Credentials),
TTL: externalRegistry.TTL,
externalSource = &authorization_evaluators.OPAExternalSource{
Endpoint: externalRegistry.Url,
SharedSecret: sharedSecret,
AuthCredentials: newAuthCredential(externalRegistry.Credentials),
TTL: externalRegistry.TTL,
}
}

var err error
Expand Down
146 changes: 146 additions & 0 deletions install/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5029,6 +5029,80 @@ kind: ClusterRole
metadata:
name: authorino-manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps/status
verbs:
- delete
- get
- patch
- update
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorino.kuadrant.io
resources:
Expand All @@ -5049,6 +5123,12 @@ rules:
- get
- patch
- update
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -5066,3 +5146,69 @@ rules:
- get
- list
- watch
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos/finalizers
verbs:
- update
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos/status
verbs:
- get
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- roles
verbs:
- create
- get
- list
- update
- watch
146 changes: 146 additions & 0 deletions install/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,80 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps/status
verbs:
- delete
- get
- patch
- update
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorino.kuadrant.io
resources:
Expand All @@ -24,6 +98,12 @@ rules:
- get
- patch
- update
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -41,3 +121,69 @@ rules:
- get
- list
- watch
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos/finalizers
verbs:
- update
- apiGroups:
- operator.authorino.kuadrant.io
resources:
- authorinos/status
verbs:
- get
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- roles
verbs:
- create
- get
- list
- update
- watch

0 comments on commit 1c23688

Please sign in to comment.