General requirements
- OS - Windows 10
- IDE - Visual Studio 2015
- Mobile or mobile emulator with running Windows 10
Pre-requisites and settings
- Download Keycloak Demo Bundle (version 1.4.0 Final)
- Setup Keycloak to use SSL (original resource)
- Create Self Signed Certificate by command:
- Move generated keycloak.jks to keycloak-demo-1.4.0.Final/keycloak/standalone/configuration
- To security-realms in keycloak-demo-1.4.0.Final/keycloak/standalone/configuration/standalone.xml add:
<security-realm name="UndertowRealm"> <server-identities> <ssl> <keystore path="keycloak.jks" relative-to="jboss.server.config.dir" keystore-password="SELECTED_PASSWORD" /> </ssl> </server-identities> </security-realm>
- And to
<server name="default-server">
element add:
keytool -genkey -alias localhost -keyalg RSA -keystore keycloak.jks -validity 10950
(answer for the
What is your first and last name?
should be DNS name (IP adress) of PC with running server). PC and mobile should be connected to the same Wi-Fi network.<https-listener name="https" socket-binding="https" security-realm="UndertowRealm" />
Starting the server
- Start the server keycloak-demo-1.4.0.Final/keycloak/bin/standalone.bat -b 0.0.0.0
- Go to http://localhost:8080/auth/admin/index.html
- Login using admin / admin
- Click on Add realm and import this configuration file
Starting and setting the web application
- Download this project and get only the Shoot directory
- Add
"auth-server-url": "/auth"
to Shoot/src/main/webapp/WEB-INF/keycloak.json - Build (
mvn clean install
) - Open Shoot/target/shoot.war (with WinRAR for example) and add keycloak.cer there
- Go to http://localhost:9990/console/App.htmland navigate to Deployments and add shoot.war
(if we deploy the .war bymvn wildfly:deploy
, we would lost added certificate)
Installing certificate to Windows 10 emulator
- Open browser(Edge) and download the certificate by navigating to
http://<IP>:8080/shoot/keycloak.cer
where IP is the name of the certificate chosen earlier. - Open and install the certificate
Preparing example app
Because this app was built for Windows Phone 8.1 platform, we need to convert the project to be executable on Windows 10, in other words the project has to target the Universal Windows Platform (UWP). There exists some scripts or nuget plugins which can do the conversion automatically, but finally there is more mess then before and you have to manually edit lot of stuffs in our case, so the most easiest way is to create new solution in VS15 for UWP and copy the source code into it.- Download the source code of example app.
- Create new solution in VS15 and import the source code into it.
- Download the aerogear-windows-oauth2 project which is actually the source code of library available as Nuget package and import it to our solution
- Next you have to edit the MainPage.xaml.cs by configuring the IP adress to the same adress as the server is running on (it is assuring that it is going to run also on real device) and then add the line adding the scope to the configuration.
- Then in aerogear-windows-oauth2 project you should edit the class AccountManager.cs as below. That is because the manifest files of Windows Phone 8.1 and Windows 10 are different and the redirect protocol (org.aerogear.Shoot) is not that easy to parse from Windows 10 file.
- Build and run the solution on one of the Windows 10 emulators. The result is shown on screenshots below.
Application flow
- You capture a photo (on emulator only this "tv noise"). Click on Keycloak icon, then you are redirected to login Keycloak page where you enter user / password (according to settings in realm). Finally we get feedback about succesfully uploaded image to our web application.
- If we check the web application then, the image is visible there.