keycloak-scim/examples/cordova-native
Gregor Tudan 3417b569c0 KEYCLOAK-2606: add support for native browsers on cordova
KEYCLOAK-2606 Added cordova native

KEYCLOAK-2606 Some more fixes and tweaks

Fix redirect in example realm

feature(cordova-native): fix universalLinks and kc options

Added 'cordova-native' to typings

Added an option to define a "default" redirectUri in keycloak.js

Added 'login' and 'logout' event to universalLinks configuration in config.xml

Improved 'cordova-native' example to always use a redirectUri and
update state after successfull logout

Setting the 'authenticated' flag for the keycloak instance to 'false'
after a logout redirect

KEYCLOAK-2606: Simplify example for cordova-native

I wanted to make it explicit which options are actually needed, so I didn't want to reuse the keycloak conf

KEYCLOAK-2606: simplify example

The update state after logout shouldn't be necessary as it is set in `keycloak.onAuthLogout = updateState;`
Not sure why it is called after the login promise...

Fixes
2018-07-18 10:51:59 +02:00
..
www KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
.gitignore KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
config.xml KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
example-realm.json KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
package-lock.json KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
package.json KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00
README.md KEYCLOAK-2606: add support for native browsers on cordova 2018-07-18 10:51:59 +02:00

Basic Cordova Example

Before running this example you need to have Cordova installed with a phone or emulator available.

Start and configure Keycloak

Start Keycloak bound to an IP address available to the phone or emulator. For example:

bin/standalone.sh -b 192.168.0.10

Open the Keycloak admin console, click on Add Realm, click on 'Choose a JSON file', selct example-realm.json and click Upload.

Navigate to applications, click on 'Cordova', select 'Installation' and in the 'Format option' drop-down select 'keycloak.json'. Download this file to the www folder.

Download '/js/keycloak.js' from the server to the www folder as well. For example:

wget http://192.168.0.10:8080/auth/js/keycloak.js

Install to Android phone or emulator

cordova platform add android
cordova run android

Once the application is opened you can login with username: 'user', and password: 'password'.

Troubleshooting

  • You always need to initialize keycloak after the 'deviceready' event. Otherwise Cordova mode won't be enabled for keycloak.js.
  • 'http://localhost' should be listed in the allowed redirects in client configuration, but never 'file:///android_asset'.