-
Notifications
You must be signed in to change notification settings - Fork 15
OIDC field mapping configuration #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| products: | ||
| - Alauda Container Platform | ||
| kind: | ||
| - Solution | ||
| --- | ||
|
|
||
| # OIDC Field Mapping Configuration | ||
|
|
||
| ## Issue | ||
|
|
||
| When integrating third-party OIDC (OpenID Connect) services, authentication callback failures are frequently encountered, with the error message typically being: | ||
|
|
||
| `Internal error occurred: failed to authenticate: missing email claim, not found \"email\" key` | ||
|
|
||
| The platform requests the default scopes `profile` and `email` during OIDC authentication. However, some third-party OIDC providers may not return standard fields in the expected format. | ||
|
|
||
| **Common error messages:** | ||
|
|
||
| - missing "email" claim: Missing email field | ||
| - missing "email_verified" claim: Missing email verification field | ||
| - missing "name" claim: Missing name field | ||
|
|
||
| ## Environment | ||
|
|
||
| - 4.x | ||
| - 3.x | ||
|
|
||
| ## Resolution | ||
|
|
||
| The platform provides a field mapping feature to handle these non-standard situations. | ||
|
|
||
| ### For Platform Version 4.x | ||
|
|
||
| 1. Navigate to Administrator → Users → IDP → Click to enter OIDC integration details → Click Update on the right side of Actions → Switch to YAML view | ||
|
|
||
| 2. Configure field mapping in the YAML: | ||
|
|
||
| ```yaml | ||
| spec: | ||
| config: | ||
| # Other configurations | ||
| # If the Provider cannot provide the email_verified field, the email verification check can be skipped. | ||
| insecureSkipEmailVerified: true | ||
|
|
||
| # Use other fields as the display name; the default is the name field. | ||
| userNameKey: display_name | ||
|
|
||
| # If the provider's /.well-known/openid-configuration provides a userinfo_endpoint, the UserInfo endpoint query can be enabled. | ||
| getUserInfo: true | ||
|
|
||
| # Field Mapping Configuration | ||
| claimMapping: | ||
| # If the provider cannot provide the email field, 'sub' can be used as a substitute. | ||
| # In addition to the sub field, other fields that can uniquely represent a user globally may also be used. | ||
| # Default email | ||
| email: sub | ||
|
|
||
| # If the provider uses 'user_groups' instead of 'groups' | ||
| # Default groups | ||
| groups: user_groups | ||
|
|
||
| # If the provider uses 'mobile' instead of 'phone' | ||
| phone: mobile | ||
| ``` | ||
|
|
||
| 3. After updating the field mappings in the IDP configuration, users can attempt to log in again using OIDC. | ||
|
|
||
| For detailed documentation related to version 4.x, please refer to: [https://docs.alauda.io/container_platform/4.1/security/users_and_roles/idp/functions/oidc_manage.html](https://docs.alauda.io/container_platform/4.1/security/users_and_roles/idp/functions/oidc_manage.html) | ||
|
|
||
| ### For Platform Version 3.x | ||
|
|
||
| 1. Execute the following commands in the global cluster: | ||
|
|
||
| ```bash | ||
| # Retrieve the connected provider(s). | ||
| kubectl get connectors -n cpaas-system | ||
|
|
||
| # Edit connector information | ||
| kubectl edit connector -n cpaas-system <connector name> | ||
| ``` | ||
|
|
||
| 2. Decode the value of the config field using Base64. | ||
|
|
||
| The configuration information of the Provider will be displayed in JSON format. At this point, you can update the configuration in the JSON according to the field configuration of version 4.x. Finally, encode the information in base64 and update it to the connector resource. | ||
|
|
||
|
Comment on lines
+83
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Provide concrete Base64 decode/encode commands and newline handling Avoid common pitfalls with trailing newlines and line-wrapping. -2. Decode the value of the config field using Base64.
-
-The configuration information of the Provider will be displayed in JSON format. At this point, you can update the configuration in the JSON according to the field configuration of version 4.x. Finally, encode the information in base64 and update it to the connector resource.
+2. Decode the `config` field (Base64), edit JSON, then re-encode:
+
+```bash
+# Decode to file
+kubectl get connector -n cpaas-system <connector-name> -o json \
+ | jq -r '.spec.config' | base64 -d > oidc-config.json
+
+# Edit JSON per 4.x field mappings
+$EDITOR oidc-config.json
+
+# Re-encode without line wraps and patch back
+ENCODED=$(base64 -w0 < oidc-config.json)
+kubectl patch connector -n cpaas-system <connector-name> --type merge -p "{\"spec\":{\"config\":\"$ENCODED\"}}"
+```🤖 Prompt for AI Agents |
||
| After updating the Connector configuration, you can use OIDC to log in to the platform again. | ||
|
|
||
| ## Root Cause | ||
|
|
||
| The root cause of this type of issue is that the ID Token returned by the third-party OIDC service lacks standard mandatory fields, preventing the system from correctly parsing user information. | ||
|
|
||
| ID Tokens contain standard claims that assert which client app logged the user in, when the token expires, and the identity of the user. | ||
|
|
||
| **Standard ID Token example:** | ||
|
|
||
| ```json | ||
| { | ||
| "iss": "http://127.0.0.1:5556/dex", | ||
| "sub": "CgcyMzQyNzQ5EgZnaXRodWI", | ||
| "aud": "example-app", | ||
| "exp": 1492882042, | ||
| "iat": 1492795642, | ||
| "at_hash": "bi96gOXZShvlWYtal9Eqiw", | ||
| "email": "jane.doe@coreos.com", | ||
| "email_verified": true, | ||
| "groups": [ | ||
| "admins", | ||
| "developers" | ||
| ], | ||
| "name": "Jane Doe" | ||
| } | ||
| ``` | ||
|
|
||
| ## Diagnostic Steps | ||
|
|
||
| 1. **Check the ID Token content**: You can use an online JWT decoding tool (such as [https://jwt.io](https://jwt.io)) to view the actual content of the ID Token and understand which fields the OIDC service provides. | ||
|
|
||
| 2. **Consult the IDP provider**: To map the required fields, consult the IDP provider's operations personnel to determine which fields were provided during authorization. | ||
|
|
||
| 3. **Verify authentication flow**: Test the OIDC authentication process to identify specific missing claims in the error messages. | ||
|
Comment on lines
+117
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add caution: don’t paste live tokens into third‑party sites Recommend local decoding to avoid leaking tokens. -1. **Check the ID Token content**: You can use an online JWT decoding tool (such as [https://jwt.io](https://jwt.io)) to view the actual content of the ID Token and understand which fields the OIDC service provides.
+1. **Check the ID Token content**: Prefer local decoding to avoid exposing tokens to third parties. Example:
+
+```bash
+# ID token structure (header.payload.signature)
+cut -d. -f2 <<< "$ID_TOKEN" | base64 -d 2>/dev/null | jq .
+```
+If using an online tool (e.g., jwt.io), never paste production tokens.🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add a security warning for insecureSkipEmailVerified
Skipping email verification lowers identity assurance. Call this out prominently.
📝 Committable suggestion
🤖 Prompt for AI Agents