Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 15, 2024
1 parent 2b12a68 commit b267cf9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions microservices-connector/config/authN-authZ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

In enterprise settings not only do we want to identify who is using a service but also what they are entitled to use. This is where authentication and authorization comes in. In contrast, API tokens provide full access by virtue of possession as long as they are valid/not expired. With that aside, we first provide the solution on AuthN and AuthZ in OPEA using Istio and JWT tokens. Another option is to leverage the oauth2-proxy with various OIDC providers for authentication and authorization. Using oauth2-proxy with Istio ensures secure, scalable access control, centralizes user management, and provides seamless single sign-on capabilities, improving overall security and user experience in complex microservices environments.


Currently we provide three kinds of setups for authentication and authorization: via fake JWT token, via JWT token generated by OIDC providers and via oauth2-proxy and OIDC providers. And here we use the chatQnA pipeline as an example.

## Prerequisite
Expand Down Expand Up @@ -40,7 +39,7 @@ Authentication and authorization are essential for securing microservices archit

### Perform authentication and authorization via fake JWT tokens

Here provides the case of authentication and authorization using fake JWT tokens. Fake JWT tokens are generated through a sample script provided by Istio community.
Here provides the case of authentication and authorization using fake JWT tokens. Fake JWT tokens are generated through a sample script provided by Istio community.

In this example, we setup rules that only users with JWT token issued by "[email protected]" and with claim "groups" equal to "group1" can access the chatQnA workload.

Expand Down Expand Up @@ -197,6 +196,7 @@ export HOST_IP=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster
export KEYCLOAK_PORT=$(kubectl get svc keycloak -o jsonpath='{.spec.ports[0].nodePort}')
export KEYCLOAK_ADDR=${HOST_IP}:${KEYCLOAK_PORT}
```

**Note:** Double check if the host ip captured is the correct ip.

Access the Keycloak admin console through the `KEYCLOAK_ADDR` to configure the users as well as roles. Use the username and password specified in the yaml file to login.
Expand Down Expand Up @@ -284,9 +284,10 @@ envsubst < $(pwd)/config/authN-authZ/chatQnA_authZ_oauth.yaml | kubectl -n chatq
**Validate authentication and authorization with UI service**

Add both host names for ChatQnA UI and backend service into /etc/hosts

```bash
sudo sed -i '1i\127.0.0.1 chatqna-service.com' /etc/hosts
sudo sed -i '1i\127.0.0.1 chatqna-ui.com' /etc/hosts
```

Open browser with address "chatqna-ui.com:${INGRESS_PORT}". Login with user `bob` and its credentials shall return a 403 error. Login with user `mary` and its credentials shall able to access the ChatQnA service.
Open browser with address "chatqna-ui.com:${INGRESS_PORT}". Login with user `bob` and its credentials shall return a 403 error. Login with user `mary` and its credentials shall able to access the ChatQnA service.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: security.istio.io/v1
kind: RequestAuthentication
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
Expand All @@ -14,4 +17,4 @@ spec:
- /realms/*
selector:
matchLabels:
istio: ingressgateway
istio: ingressgateway
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
data:
mesh: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
data:
Expand Down

0 comments on commit b267cf9

Please sign in to comment.