기본적으로 tekton을 구성하면 dashboard에는 인증기능이 없다.
Tekton 대시보드 연습 – OAuth2 프록시
GitHub OAuth 앱 만들기
“Gitea에서 Application에 OAuth2를 등록” = Gitea가 Authorization Server(=OAuth2 서버) 로 동작
- Gitea 설정 화면에서 OAuth2 Application을 등록한다는 건, “내 앱이 로그인할 때 Gitea를 아이디 제공자로 쓰겠다”는 뜻.
- Gitea에 등록하는 것은 “클라이언트 앱(redirect URI, client_id/secret을 부여받는 쪽)”.
- 권한부여/토큰 발급은 Gitea 서버가 담당.
- Gitea: OAuth2/OIDC 서버(issuer)
- 클라이언트는 (Gitea를 통해 로그인/토큰 획득)
관리자계정에서 ‘사이트관리’ > ‘Integrations’ > 어플리케이션
hm-cloud 로 생성하였다. 문서에는 메인도메인만넣는 것으로 나와있는데 subPath까지 넣어주니 에러가 해결되었음.

Redirect URIs. Please use a new line for everyURI. 이부분이 좀 중요한데,
OAuth2 표준에서 “Authorization Code Flow”의 콜백 주소를 등록하는 부분이다.
Gitea에 로그인하고 권한부여가되면 Gitea에서 인증코드를 돌려줄 목적지가 필요한데, 이때 허용된 EndPoint를 등록하는 곳이다.
생성을하게되면 Client ID정보와 Client Secret이 발급되는데 ClientSecret은 발급될때만 공개되므로 분실시 재발급해야한다.
OAuth2 Proxy
OAuth2 Application을 구성했으면, 인증 처리를 위한 기능이 필요하다.
애플리케이션을 안 뜯고도 SSO(로그인), 인증/인가, 세션 관리를 “앞단에서” 처리하기 위해 OAuth2 Proxy 가 필요하다.
Ingress와 연동해 통일된 접근제어:
NGINX/Ingress에서auth_request
(혹은 전용 어노테이션)로 oauth2-proxy에 인증을 맡깁니다.
- 인증 성공 ⇒ 헤더(
X-Auth-Request-User
,X-Auth-Request-Email
, OIDC 클레임 등)를 추가해 upstream으로 전달- 인증 실패 ⇒ 로그인 페이지로 리다이렉트
Regist Helm Repo & Update
helm repo add oauth2-proxy https://oauth2-proxy.github.io/manifests
helm repo update
사용가능 차트 조회
# head로 조회시 10개만 보임
helm search repo oauth2-proxy/oauth2-proxy --versions | head
[ubuntu@dev tekton-k8s (⎈|tk8s:tekton-demo)]$ helm search repo oauth2-proxy/oauth2-proxy --versions | head
NAME CHART VERSION APP VERSION DESCRIPTION
oauth2-proxy/oauth2-proxy 8.2.0 7.12.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 8.1.1 7.12.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 8.1.0 7.12.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 8.0.1 7.11.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 8.0.0 7.11.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 7.18.0 7.11.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 7.17.1 7.11.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 7.17.0 7.11.0 A reverse proxy that provides authentication wi...
oauth2-proxy/oauth2-proxy 7.16.0 7.11.0 A reverse proxy that provides authentication wi...
[ubuntu@dev tekton-k8s (⎈|tk8s:tekton-demo)]$
Download helm Chart
tekton 연습문서에서 oauth2-proxy 7.5.1 버전(helm chart version 6.19.1)로 테스트 되어 있어서 app버전은 맞추고 chart만 app과 맞추었음.
# 원하는 버전으로 차트 패키지를 다운로드
# helm pull oauth2-proxy/oauth2-proxy --version 6.23.1 --untar
helm pull oauth2-proxy/oauth2-proxy --version 6.19.1 --untar
Prepare OAuth2 Proxy
Gitea를 OAuth 서버로 쓸 때는
provider: github
를 유지하되, login/redeem/validate URL을 Gitea 엔드포인트로 오버라이드해야 합니다. (gpt)
Gitea Provider
# values.my.yaml (Gitea)
config:
clientID: ${CLIENT_ID} # Gitea에서 생성한 정보 입력
clientSecret: ${CLIENT_SECRET} # Gitea에서 생성한 정보 입력
cookieSecret: # 명령어로 생성해여 붙여넣음. ::: openssl rand -base64 32 | head -c 32 | base64
extraArgs:
provider: github
provider-display-name: Gitea
login-url: https://gitea.example.com/login/oauth/authorize
redeem-url: https://gitea.example.com/login/oauth/access_token
validate-url: https://gitea.example.com/api/v1/user/emails
# oauth2-proxy가 노출되는 실제 호스트명 기준
whitelist-domain: .tk8s.test
cookie-domain: .tk8s.test
redirect-url: https://tek.tk8s.test/oauth2/callback
cookie-secure: "true" # HTTPS 환경에서 true
ingress:
enabled: true
className: nginx
path: /
pathType: Prefix
hosts:
- auth.tk8s.test
labels: {}
tls:
- secretName: ssl-common
hosts:
- auth.tk8s.test
Create ns
kubectl create ns toos
Create Certs
kubectl create secret tls ssl-common --cert ./chain.pem --key ./tk8s.test.key -n tools
Deploy
helm install oauth2-proxy oauth2-proxy/oauth2-proxy -n tools -f values.yaml
dashboard Ingress수정
kubectl edit ing -n tekton-pipelines tekton-pipelines-ing
# 두줄을 annotation에 넣도록합니다.
nginx.ingress.kubernetes.io/auth-signin: https://auth.tk8s.test/oauth2/sign_in?rd=http://$host$request_uri
nginx.ingress.kubernetes.io/auth-url: http://oauth2-proxy.tools.svc.cluster.local/oauth2/auth
접속 테스트
