Skip to content

Support Keycloak #8

@kstan79

Description

@kstan79

Hi,

Thanks of this plugin and it reduce my work. I'd modify providers/provider.js to support keycloak, tested it work in ios only. Android it show blank page instead of login form (Seems SSL issue), after by pass SSL it still facing another issue which is webview no callback success status (another error which is session not exists). Need your advise how to make it work in android.

Below is the additional code of provider.js:

//add keycloak into provider.js
var TnsOaProviderKeycloak = (function () {
    function TnsOaProviderKeycloak(options,keycloakbaseurl,realm) {
        this.openIdSupport = "oid-none";
        this.providerType = "keycloak";
        this.authority = keycloakbaseurl;
        this.tokenEndpointBase = keycloakbaseurl;
        this.authorizeEndpoint = '/realms/'+realm+'/protocol/openid-connect/auth';
        this.tokenEndpoint = '/realms/'+realm+'/protocol/openid-connect/token';
        this.cookieDomains = [realm];
        this.options = options;
    }
    TnsOaProviderKeycloak.prototype.parseTokenResult = function (jsonData) {
        return jsonData;
    };
    return TnsOaProviderKeycloak;
}());
exports.TnsOaProviderKeycloak = TnsOaProviderKeycloak;

I'm not really understand how nativescript plugin system (how .ts convert to .js) work, and the plugin seems no distribute provider.ts (in fact, our project not use typescript). So I submit above code hope you can you merge into your project and benefit others keycloak user.

for usage, auth-service.js:

function configureOAuthProviderKeycloak() {
  var serverurl='https://<keycloakserver>/auth';
  var realm='keycloakrealm';
    var keycloakProviderOptions = {        
        openIdSupport: "oid-none",
        clientId: "keycloakclientid",
        clientSecret: "clientsecret",
        redirectUri: "redirecturl",        
        scopes: ["email"]
    };
    var keycloakProvider = new providers_1.TnsOaProviderKeycloak(keycloakProviderOptions,serverurl,realm);
    return keycloakProvider;
}

at landingpage, I use below:

var auth_service_1 = require("~/auth-service");
auth_service_1.configureOAuthProviders();
auth_service_1.tnsOauthLogin("keycloak");

Thanks
Ks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions