Openshift Service Mesh 2.0 provides an easy way to connect microservices in a secure and consistent manner, and to build distributed, modulable and scalable applications on top of it.
Connecting microservices and securing these connections is rather simple thanks to custom ressources such as VirtualService and DestinationRule. But what about securing the access to the resulting applications? In an enterprise context, it might be desirable to have some high-level filtering - complementary to network-based filtering - regarding which users or teams can access which applications.
Istio - the control plane of Openshift Service Mesh 2.0 - provides natively some mechanisms for such filtering, based on a JSON Web Token (JWT) that a user would embed in a cookie when requesting an application. However, the retrieval and the embedding of the JWT is left to the user, and no native mechanism exists yet to provide a full automated workflow.
In this blog post, we go through these native authentication/authorization mechanisms, and explore a way to implement a full automated workflow based on OIDC. Red Hat Single Sign-On (RHSSO) is used as the authentication/authorization entity. All the code and more detailed READMEs for each approach are available in this repository.
This tutorial assumes that a running OCP 4.6 cluster and cluster-admin user are available.
Requirements
- have an OCP 4.6 running cluster
- have a user with cluster-admin role
- have Service Mesh 2.0 installed
- have a RHSSO platform inside the cluster deployed using the RHSSO operator
- have bookinfo service mesh application example deployed
Approach 1: Using Istio native mechanisms for JWT-based authorization
In this approach, access to the bookinfo
application is restricted using Istio-related CRD RequestAuthentication and AuthorizationPolicy deployed in the cluster. A user can access the application by providing a JWT token in its HTTP request (through the HTTP Header Authorization
).
The workflow is as follows:
- the user authenticates to RHSSO and get a JWT token (not shown in the above picture);
- the user performs an HTTP request to
https://<route>/productpage
and passes along this request the JWT token; - the Istio ingress gateway (default one) forwards the request and the JWT token to the istio-proxy container of the productpage pod;
- the istio-proxy container of the productpage pod checks the validity of the JWT token depending on the
RequestAuthentication
andAuthorizationPolicy
objects deployed beforehand; - if the JWT token is valid, user accesses
/productpage
- otherwise, an error message is returned to the user (code 404, message "RBAC denied" or others).
Pros:
- the simplest approach (only 2 CR to be deployed)
- fine-grained authorization based on JWT token fields
Cons:
- no OIDC workflow: the user must get a JWT token on its own, and pass it with the HTTP request on its own
- need to define
RequestAuthentication
andAuthorizationPolicy
objects for each application to protect inside the service mesh
Approach 2: Injecting oauth2-proxy container inside the Istio ingress gateway to implement an OIDC workflow
In this approach, access to the bookinfo
application is restricted by injecting an oauth2-proxy sidecar container to the Istio ingress gateway. The oauth2-proxy will enforce user authentication with RHSSO before forwarding any request to the istio-proxy (the default container of the Istio ingress gateway). In this approach, the OIDC workflow between the user, oauth2-proxy and RHSSO is perfomed automatically.
The workflow is as follows:
- the user performs an unauthenticated HTTP request to
https://<route>/productpage
; - the oauth2-proxy inside the Istio ingress gateway pod initiates the OIDC workflow to authenticate the user; user authenticates to RHSSO (not shown on the picture);
- the user performs an authenticated HTTP request to
https://<route>/productpage
; the authentication is checked by the oauth2-proxy using HTTP cookies; - the oauth2-proxy forwards locally (same pod) the request to the istio-proxy container of the Istio ingress gateway, which in turn forwards the request to the istio-proxy container of the productpage pod;
- user accesses
/productpage
.
Pros:
- authentication enforced at the ingress gateway level (no need to define
RequestAuthentication
andAuthorizationPolicy
objects for each application) - automated OIDC workflow to authenticate the user
Cons:
- coarse-grained authorization (authenticated == authorized)
- complex setup (involve patches)
Approach 3: Combining JWT-based authorization and OIDC workflow
This approach combines the use of RequestAuthentication
and AuthorizationPolicy
objects as done for approach 1, and the injection of the oauth2-proxy container as done in the approach 2. In this approach, the oauth2-proxy container extracts the JWT token from the authentication cookie, and forwards it to the istio-proxy container alongside the HTTP request (using the X-Forwarded-Access-Token
HTTP header). As a result, an automated OIDC workflow to authenticate the user is performed, and can be, if needed, combined to a fine-grained authorization based on JWT token fields (e.g. simple auth for 'non-secure' apps, auth + JWT field for more secure apps).
The workflow is as follows:
- the user performs an unauthenticated HTTP request to
https://<route>/productpage
; - the oauth2-proxy inside the Istio ingress gateway pod initiates the OIDC workflow to authenticate the user; user authenticates to RHSSO (not shown on the picture);
- the user performs an authenticated HTTP request to
https://<route>/productpage
; the authentication is checked by the oauth2-proxy using HTTP cookies; - the oauth2-proxy extracts the JWT token from the authentication cookie and forwards it locally (same pod) alongside the HTTP request to the istio-proxy container of the Istio ingress gateway;
- the istio-proxy container of the Istio ingress gateway forwards the request and the JWT token to the istio-proxy container of the productpage pod;
- the istio-proxy container of the productpage pod checks the validity of the JWT token depending on the
RequestAuthentication
andAuthorizationPolicy
objects deployed beforehand; - if the JWT token is valid, user accesses
/productpage
- otherwise, an error message is returned to the user (code 404, message "RBAC denied" or others).
Pros:
- authentication enforced at the ingress gateway level
- automated OIDC workflow to authenticate the user
- if needed, fine-grained authorization based on JWT token fields
Cons:
- complex setup (currently involves deployment / service / route patches)
References
저자 소개
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.