auth
免费Authentication and authorization patterns for Rossoctl services
中文简介正在准备中。当前显示原文说明。
Create confidential OAuth2 clients in Keycloak for server-to-service authentication
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Create confidential OAuth2 clients in Keycloak for server-side applications using client credentials flow.
Keycloak supports two types of OAuth2 clients:
This skill focuses on confidential clients for service-to-service authentication.
keycloak_admin.create_client({
"clientId": "my-service",
"name": "My Service Client",
"enabled": True,
"protocol": "openid-connect",
"publicClient": False, # This makes it a confidential client
"serviceAccountsEnabled": True, # REQUIRED for client credentials grant
"standardFlowEnabled": False, # No authorization code flow
"directAccessGrantsEnabled": False, # No password grant
})
Critical: serviceAccountsEnabled: True is REQUIRED for the client credentials grant type. Without this, the token endpoint will reject requests with invalid_grant.
Use the python-keycloak library:
from keycloak import KeycloakAdmin
def create_confidential_client(keycloak_url, realm, admin_user, admin_pass, client_id):
"""Create a confidential OAuth2 client."""
keycloak_admin = KeycloakAdmin(
server_url=keycloak_url,
username=admin_user,
password=admin_pass,
realm_name=realm,
verify=True
)
# Create client
keycloak_admin.create_client({
"clientId": client_id,
"enabled": True,
"publicClient": False,
"serviceAccountsEnabled": True,
"standardFlowEnabled": False,
})
# Get client secret
client_uuid = keycloak_admin.get_client_id(client_id)
client_secret = keycloak_admin.get_client_secrets(client_uuid)["value"]
return client_secret
Deploy as a Kubernetes Job that runs during installation:
apiVersion: batch/v1
kind: Job
metadata:
name: my-service-oauth-secret
namespace: rossoctl-system
spec:
template:
spec:
serviceAccountName: my-service-client-registration
containers:
- name: register
image: python:3.11-slim
command: ["python", "/scripts/register.py"]
env:
- name: KEYCLOAK_URL
value: "http://keycloak-service.keycloak.svc.cluster.local:8080"
- name: KEYCLOAK_ADMIN
valueFrom:
secretKeyRef:
name: keycloak-admin
key: username
- name: KEYCLOAK_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-admin
key: password
volumeMounts:
- name: scripts
mountPath: /scripts
restartPolicy: OnFailure
volumes:
- name: scripts
configMap:
name: my-service-oauth-script
When creating secrets in other namespaces, you need cross-namespace RoleBindings:
# Role in target namespace
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: secret-creator
namespace: rossoctl-system
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "update", "patch"]
---
# RoleBinding to service account in source namespace
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: keycloak-secret-creator
namespace: rossoctl-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: secret-creator
subjects:
- kind: ServiceAccount
name: my-service-client-registration
namespace: keycloak
Avoid TLS complexity by using the internal service URL:
http://keycloak-service.keycloak.svc.cluster.local:8080
Mount the pre-existing CA bundle:
volumeMounts:
- name: trusted-ca
mountPath: /etc/pki/ca-trust/extracted/pem
readOnly: true
volumes:
- name: trusted-ca
configMap:
name: config-trusted-cabundle
items:
- key: ca-bundle.crt
path: tls-ca-bundle.pem
Different consumers expect different secret key names:
data:
OIDC_CLIENT_ID: <base64>
OIDC_CLIENT_SECRET: <base64>
OIDC_TOKEN_URL: <base64>
data:
PHOENIX_OAUTH2_CLIENT_ID: <base64>
PHOENIX_OAUTH2_CLIENT_SECRET: <base64>
data:
MLFLOW_CLIENT_ID: <base64>
MLFLOW_CLIENT_SECRET: <base64>
invalid_grantserviceAccountsEnabled: True is set on the clientSSL certificate problemAccess deniedauth:otel-oauth2-exporteropenshift:trusted-ca-bundle还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Authentication and authorization patterns for Rossoctl services
中文简介正在准备中。当前显示原文说明。
Configure MLflow with mlflow-oidc-auth plugin for Keycloak OIDC authentication
中文简介正在准备中。当前显示原文说明。
Configure OpenTelemetry Collector with OAuth2 authentication for trace export
中文简介正在准备中。当前显示原文说明。
CI pipeline monitoring, status checks, and PR validation workflows
中文简介正在准备中。当前显示原文说明。
Monitor running CI jobs, wait for completion, create tasks for results
中文简介正在准备中。当前显示原文说明。
Check PR CI status - all checks, failures, test results, and artifacts
中文简介正在准备中。当前显示原文说明。