User guide: Hello World
Requirements
- Kubernetes server
Create a containerized Kubernetes server locally using Kind:
1. Create the namespace
2. Deploy the Talker API
The Talker API is just an echo API, included in the Authorino examples. We will use it in this guide as the service to be protected with Authorino.
kubectl -n hello-world apply -f https://raw.githubusercontent.com/kuadrant/authorino-examples/main/talker-api/talker-api-deploy.yaml
# deployment.apps/talker-api created
# service/talker-api created
3. Setup Envoy
kubectl -n hello-world apply -f https://raw.githubusercontent.com/kuadrant/authorino-examples/main/hello-world/envoy-deploy.yaml
# configmap/envoy created
# deployment.apps/envoy created
# service/envoy created
Forward requests on port 8000 to the Envoy pod running inside the cluster:
4. Consume the API (unprotected)
5. Protect the API
Install the Authorino Operator
curl -sL https://raw.githubusercontent.com/Kuadrant/authorino-operator/main/utils/install.sh | bash -s
Deploy Authorino
kubectl -n hello-world apply -f https://raw.githubusercontent.com/kuadrant/authorino-examples/main/hello-world/authorino.yaml
# authorino.operator.authorino.kuadrant.io/authorino created
The command above will deploy Authorino as a separate service (in contrast to as a sidecar of the Talker API and other architectures). For other variants and deployment options, check out the Getting Started section of the docs, the Architecture page, and the spec for the Authorino
CRD in the Authorino Operator repo.
6. Consume the API behind Envoy and Authorino
curl http://talker-api-authorino.127.0.0.1.nip.io:8000/hello -i
# HTTP/1.1 404 Not Found
# x-ext-auth-reason: Service not found
Authorino does not know about the talker-api-authorino.127.0.0.1.nip.io
host, hence the 404 Not Found
. Teach it by applying an AuthConfig
.
7. Apply an AuthConfig
kubectl -n hello-world apply -f https://raw.githubusercontent.com/kuadrant/authorino-examples/main/hello-world/authconfig.yaml
# authconfig.authorino.kuadrant.io/talker-api-protection created
8. Consume the API without credentials
curl http://talker-api-authorino.127.0.0.1.nip.io:8000/hello -i
# HTTP/1.1 401 Unauthorized
# www-authenticate: APIKEY realm="api-clients"
# x-ext-auth-reason: credential not found
Grant access to the API with a tailor-made security scheme
Check out other user guides for several AuthN/AuthZ use-cases and instructions to implement them using Authorino. A few examples are:
- Authentication with API keys
- Authentication with JWTs and OpenID Connect Discovery
- Authentication with Kubernetes tokens (TokenReview API)
- Authorization with Open Policy Agent (OPA) Rego policies
- Authorization with simple JSON pattern-matching rules (e.g. JWT claims)
- Authorization with Kubernetes RBAC (SubjectAccessReview API)
- Fetching auth metadata from external sources
- Token normalization
Cleanup
If you have started a Kubernetes cluster locally with Kind to try this user guide, delete it by running:
Otherwise, delete the namespaces created in step 1 and 5:
To uninstall the Authorino Operator and manifests (CRDs, RBAC, etc), run: