Skip to content

Authentication for mgmt route and service #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ spec:
nullable: true
type: object
x-kubernetes-preserve-unknown-fields: true
authProxyImage:
description: AuthProxyImage (optional) overrides the default image
for the auth-proxy
type: string
autoscaler:
description: Configuration related to autoscaling
properties:
Expand Down
31 changes: 31 additions & 0 deletions deploy/internal/deployment-endpoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ spec:
secret:
secretName: noobaa-server
optional: true
- name: auth-endpoint
secret:
secretName: endpoint-auth-proxy
optional: true
containers:
- name: endpoint
image: NOOBAA_CORE_IMAGE
Expand Down Expand Up @@ -161,6 +165,33 @@ spec:
tcpSocket:
port: 6001 # ready when s3 port is open
timeoutSeconds: 5
- name: oauth-proxy
image: quay.io/openshift/origin-oauth-proxy:4.16
imagePullPolicy: IfNotPresent
ports:
- name: endpoint-proxy
containerPort: 7003
protocol: TCP
args:
- -https-address=:7003
- -provider=openshift
- -email-domain=*
- -openshift-service-account=noobaa-endpoint
- -client-id=system:serviceaccount:noobaa:noobaa-endpoint
- -upstream=http://localhost:7004
- -tls-cert=/etc/endpoint-tls/tls.crt
- -tls-key=/etc/endpoint-tls/tls.key
- -cookie-secret-file=/etc/proxy-secrets/session_secret
- -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- -openshift-sar={"resource":"services","name":"s3","namespace":"noobaa","verb":"get"}
- -openshift-delegate-urls={"/":{"resource":"services","namespace":"noobaa","verb":"get"}}
volumeMounts:
- name: s3-secret
mountPath: /etc/endpoint-tls
readOnly: true
- name: auth-endpoint
mountPath: /etc/proxy-secrets
readOnly: true
securityContext:
runAsUser: 0
runAsGroup: 0
2 changes: 1 addition & 1 deletion deploy/internal/route-mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: noobaa-mgmt
spec:
port:
targetPort: mgmt-https
targetPort: mgmt-proxy
tls:
termination: reencrypt
insecureEdgeTerminationPolicy: Redirect
Expand Down
7 changes: 7 additions & 0 deletions deploy/internal/secret-core-sa-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-core-sa-token
annotations:
kubernetes.io/service-account.name: "noobaa-core"
type: kubernetes.io/service-account-token
4 changes: 4 additions & 0 deletions deploy/internal/service-mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ spec:
name: bg-https
- port: 8446
name: hosted-agents-https
- name: mgmt-proxy
port: 8447
protocol: TCP
targetPort: mgmt-proxy
1 change: 1 addition & 0 deletions deploy/internal/service-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ spec:
name: md-https
- port: 7004
name: metrics
targetPort: endpoint-proxy

32 changes: 32 additions & 0 deletions deploy/internal/statefulset-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,42 @@ spec:
path: token
# For testing purposes change the audience to api
audience: openshift
- name: secret-mgmt-auth-proxy
secret:
defaultMode: 420
secretName: mgmt-auth-proxy
securityContext:
runAsUser: 10001
runAsGroup: 0
containers:
- name: oauth-proxy
#image: quay.io/openshift/origin-oauth-proxy:4.16
image: NOOBAA_AUTH_PROXY_IMAGE
imagePullPolicy: IfNotPresent
ports:
- name: mgmt-proxy
containerPort: 8447
protocol: TCP
args:
- -https-address=:8447
- -provider=openshift
- -email-domain=*
- -client-id=system:serviceaccount:noobaa:noobaa-core
- -openshift-service-account=noobaa-core
- -upstream=http://localhost:8080
- -tls-cert=/etc/tls/private/tls.crt
- -tls-key=/etc/tls/private/tls.key
- -cookie-secret-file=/etc/proxy/secrets/session_secret
- -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- -openshift-sar={"resource":"services","name":"noobaa-mgmt","namespace":"noobaa","verb":"get"}
- -openshift-delegate-urls={"/":{"resource":"services","namespace":"noobaa","verb":"get"}}
volumeMounts:
- mountPath: /etc/tls/private
name: mgmt-secret
readOnly: true
- mountPath: /etc/proxy/secrets
name: secret-mgmt-auth-proxy
readOnly: true
#----------------#
# CORE CONTAINER #
#----------------#
Expand Down
11 changes: 11 additions & 0 deletions deploy/role_binding_core_auth_delegator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: core-auth-proxy-auth-delegator
subjects:
- kind: ServiceAccount
name: noobaa-core
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: 'system:auth-delegator'
10 changes: 10 additions & 0 deletions deploy/role_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ rules:
- securitycontextconstraints
verbs:
- use
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- get
- create
- update
- list
- watch
3 changes: 2 additions & 1 deletion deploy/service_account_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: noobaa-core

annotations:
serviceaccounts.openshift.io/oauth-redirectreference.noobaa-core: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"noobaa-mgmt"}}'
2 changes: 2 additions & 0 deletions deploy/service_account_endpoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: noobaa-endpoint
annotations:
serviceaccounts.openshift.io/oauth-redirecturi.endpoint: "//:7004"
4 changes: 4 additions & 0 deletions pkg/apis/noobaa/v1alpha1/noobaa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type NooBaaSpec struct {
// +optional
DBImage *string `json:"dbImage,omitempty"`

// AuthProxyImage (optional) overrides the default image for the auth-proxy
// +optional
AuthProxyImage *string `json:"authProxyImage,omitempty"`

// DBConf (optional) overrides the default postgresql db config
// +optional
DBConf *string `json:"dbConf,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading