How to pass keycloak login page language with URL - keycloak

is it possible to pass language with a login URL?
I know now Keycloak supports multiple languages and after enabling this feature I can use it. Currently, I can only change that language after going to the login page. I want to show the login page with the given language. Is there any way to pass language with the login page URL using a query parameter or header value?
After loading the login page I checked it URL and end of that URL have a query parameter like kc_locale=en. I try to use this query parameter but it not work.

In version 7.0.0+ below format works:
https://...../auth/realms/..../protocol/openid-connect/auth?client_id=account&redirect_uri=...&state=0&response_type=code&scope=openid&**kc_locale=cs**
For version 13.0.0+ use element ui_locales=cs.

I`m using v12, on the create url function you can pass the locale as option.
keyCloakClient.createLoginUrl({locale: 'it'});
This adds an &ui_locales=it appendix to the url and loads the Keycloak app in the specific language.
See KeycloakLoginOptions.

You should try something beforehand:
- dont set any default language in your kc-client-config nore in the user prefs
- change your browser language to french and try to login. Is the login page in french?
- change your brwoser language to english any try to login. Is the login page in english?
We have a multi-language app here (Angular/Spring) and found that the language is determined by browser settings.

Related

GWT dynamic localization without appending parameters in URL

As per the GWT docs, there are two ways two internationalize my GWT app. One is, declare the language in the HTML itself (hardcoding) through meta tags, another is to use a query param in the URL (like &locale=de).
My webapp is dynamic,different users from different locales will be using it, so the first option is not viable. The 2nd option is fine, but somehow, appending query params to a URL is my pet peeve. I tried to make it dynamic by doing something like $("head).append("<meta name='gwt:property' content='locale=de'>"); first thing on onModuleLoad, it doesn't work.
My app will actually be a redirection, some other web-page will contain a redirection like foo.com&locale=de. Based on that, it will load the required locale fine. But after that, I want to reload it again without showing the query param in the URL, taking the locale information from cookies which can be set in the first load. Is it possible to do so?
There is a third option using cookie.
Reference - GWT Internationalization for dynamically generated content
Ensure you set locale value to the cookie or have a default value for your cookie before user chooses his locale. In our case user chooses a language before login ( where i set the cookie locale value for the user) and read this into the gwt application on load.
Adding the parameter to a model (in a Controller) and picking it up on the client (in a *.jsp) will work for you?
<meta name="gwt:property" content="locale=${locale}">
Then you just need to refresh the page and reset the locale value in a controller. Add the meta-tag code in your html/jsp page, it should be there prior to page loading.
onModuleLoad works with code already loaded to the browser window, so appending meta after loading will not work.

How to redirect user in bootstrap after confirmation in Zend Framework?

I'm just new to Zend Framework. Currently what I'm trying to do is when user access my website
they will first see a select box with two language such as english and germany to choose.
Only when they make a selection, the browser will redirect them to the index controller of that specific language page.
So my question is how to make a select box in bootstrap file or any kind of possible ways to do that and how to redirect user after that? Any solution will be much appreciated!
Don't ever use bootstrap file (and I'm talking about both Bootstrap.php and index.php) for this kind of operations. First, it just won't work the way you ask; second, you'll mess your app's structure big time.
Instead you may use one of the following approaches:
1) add some predispatch hook that will check whether the choice has already been made by checking the user's cookies. If it is, proceed with request as usual (probably setting some Zend_Registry lang variable to be used later), if not, redirect for the language choosing page; the latter should store the choice made in cookies.
2) implement a simple rule in your Router/mod_rewrite: when the requested URL contains 'the language part' (http://example.com/lang/xx/... or just http://example.com/xx/...), it automatically uses this part so set the lang param. If not, the request is automatically redirected to the language choosing page. The latter, in turn, leads the user to a language-specific page, where all the links are made language-specific.
The latter approach is inferior, in my opinion, as user will have to use a language-tuned gateway all the time. But you don't have to store this info in cookies.
You could make a plugin that use the preDispatch event to look if the language has been chosen (e.g stored in cookie or session) and redirect to the landing page if not.
Look here zend framework plug-in - predispatch()
and the ZF's action plugin documentation.
That's what I do to force login in my app.
Now in your position what I would really do would be detecting the language of the user with a fallback to English and a switch widget somewhere in your navbar.

Why is my application's authentication page different to everyone else's?

As per the Authentication Documentation, I'm directing my user's to the following URL to initiate the authentication flow:
https://www.facebook.com/dialog/oauth?client_id=251747341532139&redirect_uri=https://www.facebook.com/connect/login_success.html
However, instead of the login page looking like:
... (i.e. like it does in the documentation and in other Apps I've created and used), it looks like this...
Does anyone know why?
I've tracked the redirects that the page makes, and it's as follows:
https://www.facebook.com/dialog/oauth?client_id=251747341532139&redirect_uri=https://www.facebook.com/connect/login_success.html
https://www.facebook.com/connect/uiserver.php?app_id=251747341532139&method=permissions.request&display=page&next=https://www.facebook.com/connect/login_success.html&response_type=code&fbconnect=1
https://www.facebook.com/login.php?api_key=251747341532139&skip_api_login=1&display=page&cancel_url=https://www.facebook.com/connect/login_success.html?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&fbconnect=1&next=https://www.facebook.com/connect/uiserver.php?method=permissions.request&app_id=251747341532139&display=page&redirect_uri=https%253A%252F%252Fwww.facebook.com%252Fconnect%252Flogin_success.html&response_type=code&fbconnect=1&from_login=1&rcount=1
Application type is set to Native/Desktop, and I've set the App Integration to "Website".
If the language I'm using makes any difference, I'm using C#, and setting the Url of System.Windows.Form.WebBrowser.
As per the above comments, you can use the display parameter in the URL to control which kind of dialog to show, as you would normally do with the JS SDK.
Your URL becomes:
https://www.facebook.com/dialog/oauth?client_id=xx&redirect_uri=yy&display=popup

How would I find what page a user comes from?

I am looking for a way to detect which page a user comes from (the users referring page). If the user does not come from a page called "index.php", they should be redirected to a page, like, google.com. Any programming language that can be embedded into an html file. Thanks!
you can get the previouse url by :
$_SERVER['HTTP_REFERER']
in some cases this can be forbidden by the browser user settings
'HTTP_REFERER' The address of the page (if any) which referred the
user agent to the current page. This is set by the user agent. Not all
user agents will set this, and some provide the ability to modify
HTTP_REFERER as a feature. In short, it cannot really be trusted.
check it on the php manual
http://php.net/manual/en/reserved.variables.server.php
Look at the HTTP Referer header field?
You can use the HTTP referrer header: http://en.wikipedia.org/wiki/HTTP_referrer
There's a tutorial here on how to access it using javascript.
You would use the header called Referer [sic] . See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (section 14.36)
Obtain its value however you want.

How to disable localization for facebook like button

Facebook like button looks like "Мне нравится" on my russuin windows. How to disable this behavior? I want to see the same button on all browser and platfroms.
the language is set in the code (in this case 'en_US'):
<script src="http://connect.facebook.net/en_US/all.js#appId=XXXXXXXXX&xfbml=1"></script>
here's a list of all language codes:
facebook locales
yours is probably ru_RU so replace that with the code for your preferred language
Facebook locales follow ISO language and country codes respectively, concatenated by an underscore.
If the user is currently logged into Facebook, it will display in their localized language. If not, I believe it defaults to the language you specify in the script file include.