Skip to content

Commit 0f5cef1

Browse files
authored
authN-authZ: update configs (#378)
* update configs to return user info headers * add back redis deployment for oauth2-proxy * update service names * fix minor issues Signed-off-by: Ruoyu Ying <[email protected]>
1 parent fa9788d commit 0f5cef1

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

authN-authZ/auth-istio/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ In this example, we setup rules that only users with JWT token issued by "testin
5858
```sh
5959
# make sure running under authN-authZ/auth-istio folder
6060
# apply the yaml to request authentication using JWT token
61-
kubectl apply -f $(pwd)/$(DEPLOY_METHOD)/chatQnA_authZ_fakejwt.yaml -n chatqa
61+
kubectl apply -f $(pwd)/$DEPLOY_METHOD/chatQnA_authZ_fakejwt.yaml -n chatqa
6262

6363
# apply the yaml file to request that only JWT token with
6464
# issuer & sub == "[email protected]" and groups belongs to group1
6565
# can access the endpoint of chatQnA service
66-
kubectl apply -f $(pwd)/$(DEPLOY_METHOD)/chatQnA_authN_fakejwt.yaml -n chatqa
66+
kubectl apply -f $(pwd)/$DEPLOY_METHOD/chatQnA_authN_fakejwt.yaml -n chatqa
6767
```
6868

6969
After applying these two yaml files, we have setup the policy that only user with a valid JWT token (with valid issuer and claims) could access the pipeline endpoint.
@@ -151,14 +151,14 @@ Use the commands to apply the authentication and authorization rules.
151151
152152
```bash
153153
# export the router service through istio ingress gateway
154-
kubectl apply -f $(pwd)/$(DEPLOY_METHOD)/chatQnA_router_gateway.yaml
154+
kubectl apply -f $(pwd)/$DEPLOY_METHOD/chatQnA_router_gateway.yaml
155155
156156
# 'envsubst' is used to substitute envs in yaml.
157157
# use 'sudo apt-get install gettext-base' to install envsubst if it does not exist on your machine
158158
# apply the authentication and authorization rule
159159
# these files will restrict user access with valid token (with valid issuer, username and realm role)
160-
envsubst < $(pwd)/$(DEPLOY_METHOD)/chatQnA_authN_keycloak.yaml | kubectl -n chatqa apply -f -
161-
envsubst < $(pwd)/$(DEPLOY_METHOD)/chatQnA_authZ_keycloak.yaml | kubectl -n chatqa apply -f -
160+
envsubst < $(pwd)/$DEPLOY_METHOD/chatQnA_authN_keycloak.yaml | kubectl -n chatqa apply -f -
161+
envsubst < $(pwd)/$DEPLOY_METHOD/chatQnA_authZ_keycloak.yaml | kubectl -n chatqa apply -f -
162162
```
163163
164164
User could customize the chatQnA_authZ_keycloak.yaml to reflect roles, groups or any other claims they defined in the OIDC provider for the user.
@@ -261,6 +261,7 @@ export CLIENT_SECRET=<YOUR_CLIENT_SECRET>
261261
# Using bash here. More methods found here:
262262
# https://oauth2-proxy.github.io/oauth2-proxy/configuration/overview#generating-a-cookie-secret
263263
export COOKIE_SECRET=$(dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 | tr -d -- '\n' | tr -- '+/' '-_' ; echo)
264+
kubectl create ns oauth2-proxy
264265
envsubst < $(pwd)/oauth2_install.yaml | kubectl apply -f -
265266
```
266267
@@ -270,7 +271,7 @@ Here we expose the chatQnA endpoint through the ingress gateway and then install
270271
271272
```bash
272273
# expose chatqna endpoint
273-
kubectl apply -f $(pwd)/$(DEPLOY_METHOD)/chatQnA_router_gateway_oauth.yaml
274+
kubectl apply -f $(pwd)/$DEPLOY_METHOD/chatQnA_router_gateway_oauth.yaml
274275
# build chatqna UI image if not exist on your machine
275276
git clone https://github.com/opea-project/GenAIExamples.git
276277
cd GenAIExamples/ChatQnA/docker/ui/
@@ -280,7 +281,11 @@ docker save -o ui.tar opea/chatqna-conversation-ui:latest
280281
sudo ctr -n k8s.io image import ui.tar
281282
# install chatqna conversation UI
282283
cd && cd GenAIInfra
283-
helm install chatqna-ui $(pwd)/helm-charts/common/chatqna-ui --set BACKEND_SERVICE_ENDPOINT="http://${INGRESS_HOST}:${INGRESS_PORT}/",DATAPREP_SERVICE_ENDPOINT="http://${INGRESS_HOST}:${INGRESS_PORT}/dataprep"
284+
if [ "${DEPLOY_METHOD}" = "gmc-based" ]; then
285+
helm install chatqna-ui $(pwd)/helm-charts/common/chatqna-ui --set BACKEND_SERVICE_ENDPOINT="http://chatqna-service.com:${INGRESS_PORT}/",DATAPREP_SERVICE_ENDPOINT="http://chatqna-service.com:${INGRESS_PORT}/dataprep"
286+
else
287+
helm install chatqna-ui $(pwd)/helm-charts/common/chatqna-ui --set BACKEND_SERVICE_ENDPOINT="http://chatqna-service.com:${INGRESS_PORT}/v1/chatqna",DATAPREP_SERVICE_ENDPOINT="http://chatqna-service.com:${INGRESS_PORT}/v1/dataprep"
288+
fi
284289
# expose ui service outside
285290
kubectl apply -f $(pwd)/chatQnA_ui_gateway.yaml
286291
```
@@ -292,6 +297,7 @@ Here we apply the authentication and authorization rules.
292297
```bash
293298
# Before applying the authorization rule, need to add the oauth2-proxy as the external authorization provider
294299
kubectl apply -f $(pwd)/chatQnA_istio_external_auth.yaml
300+
kubectl rollout restart deployment/istiod -n istio-system
295301
# 'envsubst' is used to substitute envs in yaml.
296302
# use 'sudo apt-get install gettext-base' to install envsubst if it does not exist on your machine
297303
# apply the authentication and authorization rule

authN-authZ/auth-istio/chatQnA_ui_gateway.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ spec:
4242
prefix: /
4343
route:
4444
- destination:
45-
host: ui.default.svc.cluster.local
45+
host: chatqna-ui.default.svc.cluster.local
4646
port:
4747
number: 5174

authN-authZ/auth-istio/helm-chart-based/chatQnA_router_gateway_oauth.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ spec:
3131
http:
3232
- match:
3333
- uri:
34-
prefix: /
34+
prefix: /v1/chatqna
3535
route:
3636
- destination:
3737
host: chatqna.chatqa.svc.cluster.local
3838
port:
3939
number: 8888
40+
- match:
41+
- uri:
42+
prefix: /v1/dataprep
43+
route:
44+
- destination:
45+
host: chatqna-data-prep.chatqa.svc.cluster.local
46+
port:
47+
number: 6007

authN-authZ/auth-istio/oauth2_install.yaml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ data:
3333
# Redirect url
3434
redirect_url="http://chatqna-ui.com:${INGRESS_PORT}/oauth2/callback"
3535
#extra attributes
36-
pass_host_header = true
3736
reverse_proxy = true
3837
auth_logging = true
3938
cookie_httponly = true
@@ -42,6 +41,8 @@ data:
4241
email_domains = "*"
4342
pass_access_token = true
4443
pass_authorization_header = true
44+
pass_basic_auth = true
45+
pass_user_headers = true
4546
request_logging = true
4647
set_authorization_header = true
4748
set_xauthrequest = true
@@ -58,6 +59,46 @@ metadata:
5859
---
5960
apiVersion: apps/v1
6061
kind: Deployment
62+
metadata:
63+
name: redis
64+
namespace: oauth2-proxy
65+
spec:
66+
selector:
67+
matchLabels:
68+
app: redis
69+
replicas: 1
70+
template:
71+
metadata:
72+
labels:
73+
app: redis
74+
spec:
75+
containers:
76+
- name: redis
77+
image: redis:latest
78+
ports:
79+
- containerPort: 6379
80+
resources:
81+
limits:
82+
cpu: "0.5"
83+
memory: "512Mi"
84+
command: ["redis-server"]
85+
args: ["--save", "", "--appendonly", "no"]
86+
---
87+
apiVersion: v1
88+
kind: Service
89+
metadata:
90+
name: redis-service
91+
namespace: oauth2-proxy
92+
spec:
93+
selector:
94+
app: redis
95+
ports:
96+
- protocol: TCP
97+
port: 6379
98+
targetPort: 6379
99+
---
100+
apiVersion: apps/v1
101+
kind: Deployment
61102
metadata:
62103
labels:
63104
app: oauth2-proxy
@@ -94,7 +135,7 @@ apiVersion: v1
94135
kind: Service
95136
metadata:
96137
labels:
97-
app: oauth-proxy
138+
app: oauth2-proxy
98139
name: oauth-proxy
99140
namespace: oauth2-proxy
100141
spec:
@@ -104,7 +145,7 @@ spec:
104145
protocol: TCP
105146
targetPort: 4180
106147
selector:
107-
app: oauth-proxy
148+
app: oauth2-proxy
108149
sessionAffinity: None
109150
type: ClusterIP
110151
status:

0 commit comments

Comments
 (0)