Added ui_locales support and resolve localized client names. - #4629
Added ui_locales support and resolve localized client names.#4629SajidMannikeri17 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe change propagates OAuth ChangesLocalized metadata and locale propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client
participant OAuthAuthorizationService
participant OAuthParameters
participant PARService
participant LoginRedirect
participant GetFlowMetadata
participant BuildApplicationMetadata
Client->>OAuthAuthorizationService: Send ui_locales
OAuthAuthorizationService->>OAuthParameters: Store UILocales
PARService->>OAuthParameters: Store ui_locales
OAuthAuthorizationService->>LoginRedirect: Propagate ui_locales
GetFlowMetadata->>BuildApplicationMetadata: Pass resolved language
BuildApplicationMetadata->>BuildApplicationMetadata: Select localized application name
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/internal/actorprovider/utils.go`:
- Around line 135-149: Update matchByBaseLanguage in
backend/internal/actorprovider/utils.go#L135-L149 to normalize the requested and
candidate language tags, return an exact tag match before falling back by base
language, and use a stable ordering when multiple candidates share the base
language. Add the regression test in
backend/internal/actorprovider/utils_test.go#L183-L207 with both fr and fr-CA
entries, asserting that a fr-CA request selects the exact localized name.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 394ae51d-13e9-4fc7-94b9-e8ffd5bad43b
📒 Files selected for processing (7)
backend/internal/actorprovider/utils.gobackend/internal/actorprovider/utils_test.gobackend/internal/flow/flowmeta/service.gobackend/internal/oauth/oauth2/authz/service.gobackend/internal/oauth/oauth2/constants/constants.gobackend/internal/oauth/oauth2/model/parameter.gobackend/internal/oauth/oauth2/par/service.go
Signed-off-by: Sajid Mannikeri <sajid.mannikeri@ad.infosys.com>
243b238 to
7668ea8
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
| if desc, ok := attrs["description"].(string); ok { | ||
| meta.Description = desc | ||
| } | ||
| if localized := resolveLocalizedName(attrs["nameLangMap"], lang); localized != "" { |
There was a problem hiding this comment.
Are we storing a key called nameLangMap in the database? I couldn't find any valid usages.
Also we already decode the name field at line 86 and set it to metadata. But here we override it again. In our design, if the name can be localized/ stored as a localized field, stored name field should contain a i18n key (I.e. attrs["name"].(string) will be a i18n key).
Then it should be resolved by invoking the i18n mgt service. This resolution logic is a responsibility of the i18n package. I don't prefer to have i18n related logic in other packages.
There was a problem hiding this comment.
On a side note, if the frontend gate app is getting the requested locale, it should be able to resolve it based on the flow meta response. Currently also if the application is created with a localizable name (i.e. if the application name is a i18n key), flow/meta response will contain the localizable application name.
Ex:
{
...
"application": {
"name": "{{t(custom:console.app.name)}}",
...Gate should be able to resolve it with the i18n translations returned in the same flow/meta response.
"i18n": {
"languages": [
"en-US"
],
"language": "en-US",
"totalResults": 1608,
"translations": {
"custom": {
"console.app.name": "Console"
},
Purpose
Fixes two i18n bugs in the OIDC authorization / flow-metadata pipeline:
ui_localesfrom the/authorizerequest was read into the request context but never forwarded anywhere — it never reached the login page, so it had no effect on the UI language./flow/meta'sapplication.namealways returned the client's flat default name, ignoring the requested UI language even when the RP had registered per-language names.Approach
ui_localesforwarding — addedRequestParamUILocales; extractedui_localesin both the standard (authz/service.go) and PAR (par/service.go) authorization paths into a newOAuthParameters.UILocalesfield; forwarded it into the login-page redirect query params alongsideauthId/applicationId/executionIdininitiateFlowAndStoreRequest.Localized client name —
flowmeta.GetFlowMetadataalready resolves the requested language once per request; thatlangis now threaded throughpopulateTypeMetadataintoactorprovider.BuildApplicationMetadata, which resolves a per-language name from an optionalnameLangMapattribute via a newresolveLocalizedName/matchByBaseLanguagehelper. Matching is by BCP-47 base language (golang.org/x/text/language) rather than literal string equality, so 2-letter and 3-letter ISO codes ("hi"vs"hin") and region-qualified tags ("fr-CA") all resolve correctly; an exact tag match is preferred over a base-language match, with sorted (deterministic) iteration when multiple candidates share a base language. Falls back to English, then the existing default name, if nothing matches — response shape is unchanged.Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
Summary by CodeRabbit
ui_localesparameter.