Skip to content
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

add option for ui_localales query param for proper login page localization #21

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public class DefaultKeycloakParameters : IKeycloakParameters
/// - Default: If not specified, an exception will be thrown if and error from Keycloak authentication is received.
/// </remarks>
public string AuthResponseErrorRedirectUrl { get; set; }
/// <summary>
/// OPTIONAL: Query param for login page in order to get the desired locale login page, sending ui_locales query parameter
/// By default keycloak will server the login page in this priority
/// 1. kc_locale query parameter
/// 2. KEYCLOAK_LOCALE cookie value
/// 3. User’s preferred locale if a user instance is available
/// 4. ui_locales query parameter
/// 5. Accept-Language request header
/// 6. Realm’s default language
/// </summary>

public string UiLocales { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public interface IKeycloakParameters
bool DisableRefreshTokenSignatureValidation { get; }
bool DisableAllRefreshTokenValidation { get; }
string AuthResponseErrorRedirectUrl { get; }

string UiLocales { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Keycloak.IdentityModel/Utilities/OidcDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ public HttpContent BuildAuthorizationEndpointContent(Uri requestUri, string stat
if (!string.IsNullOrWhiteSpace(_options.IdentityProvider))
parameters.Add(Constants.KeycloakParameters.IdpHint, _options.IdentityProvider);

if (!string.IsNullOrWhiteSpace(_options.UiLocales))
parameters.Add(Protocols.OpenIdConnectParameterNames.UiLocales, _options.UiLocales);

return new FormUrlEncodedContent(parameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,16 @@ public KeycloakAuthenticationOptions()
/// </remarks>
public string AuthResponseErrorRedirectUrl { get; set; }

/// <summary>
/// OPTIONAL: Query param for login page in order to get the desired locale login page, sending ui_locales query parameter
/// By default keycloak will server the login page in this priority
/// 1. kc_locale query parameter
/// 2. KEYCLOAK_LOCALE cookie value
/// 3. User’s preferred locale if a user instance is available
/// 4. ui_locales query parameter
/// 5. Accept-Language request header
/// 6. Realm’s default language
/// </summary>
public string UiLocales { get; set; }
}
}
}