Giter VIP home page Giter VIP logo

qs-custom-forms's Introduction

Custom login, logout and error forms for Qlik Sense

Simple JavaScript application to customize login, logout and error forms in Qlik Sense.

Getting Started

Prepare your custom forms, follow deployment instruction and update Qlik Sense by executing one command. This extension keeps original forms unchanged, just imports new ones and changes some settings in Qlik Proxy, so you can easy restore default settings.

Prerequisites

Qlik Sense November 2017 or above, Node.js with npm modules: request, fs

Installing

Install node.js and required modules: request and fs. Copy custom_forms.js to any directory. Make sure that custom_forms.js script can access Qlik Sense cerficates (line 5 with path), if not export them form QMC. Update variable hostname (line 10) if needed.

Using

Prepare you custom forms: login, logout and error based on attached html samples. You can also extract them from Qlik Sense using extract_orig_forms.js utility to get the latest versions. If you want to redirec user after logout (for example in SSO scenarions) use logout with redirection sample. Each form must be one html file, so include all resources as css, js, images etc in html. Copy forms to the directory where custom_forms.js exists. This utility will read your html forms from following files: login_custom.html, logout_custom.html, error_custom.html, encode them and update Qlik Proxy properties. Open windows Power Shell as Administrator, go to folder with custom_forms.js and execute command: "node custom_forms". Use restore_org.js to go back to original Qlik Sense forms.

Qlik Sense configuration

To enable login form, go to QMC, Virtual Proxy and change 'Windows authenctication pattern' to Form.

qs-custom-forms's People

Contributors

christofschwarz avatar kreta99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qs-custom-forms's Issues

Multinode support

/********* Custom login, logout and error forms + RESTORATION ************/ /* USAGE: node custom_forms [node_number] [restore] i.e. setting custom forms for 1st proxy: node custom_forms 0 i.e. restoring login forms for 1st proxy: node custom_forms 0 restore */ // Change following in multinode
// node to be changed
console.log("\x1b[0m")

var isRestore= process.argv[2]=="restore" ? true :false;

var fs = require('fs');
var request = require('request');

var dir_cert = "C:\ProgramData\Qlik\Sense\Repository\Exported Certificates\.Local Certificates\";

var hostname = 'localhost'; //Qlik Sense host name

var options = {
uri: 'https://' + hostname + ':4242/qrs/ProxyService?xrfkey=1234567891234567',
headers: {'content-type': 'application/json',
'X-Qlik-xrfkey': '1234567891234567',
'X-Qlik-user': 'UserDirectory = Internal; UserId= sa_repository'},
method: 'GET',
json: true,
ca: fs.readFileSync(dir_cert + "root.pem"),
key: fs.readFileSync(dir_cert +"client_key.pem"),
cert: fs.readFileSync(dir_cert +"client.pem"),
rejectUnauthorized: false
};

//Get Proxy
request(options, function (error, response, body) {
if(error){
console.log("Error: " + error);
}
else{
//console.log(response);
//getProxyProp(body);
printProxies(body);
}
});
function printProxies(b){
var px=[];
var pxCnt=b.length;
for (let r in b){
//console.log(r);
//console.log(b[r]);
var proxyid = b[r].id;

	options.uri = 'https://' + hostname + ':4242/qrs/ProxyService/' + proxyid + '?xrfkey=1234567891234567';
		request(options, function (error, response, body) {
		if(error){
			console.log("Error: " + error);
		}
		else{				
			
			
			px.push({"id":body.id,"name":body.serverNodeConfiguration.name});
			
			// Once everything completed
			if (pxCnt===px.length){
				console.log("Select proxy:");
				for (let r in px ){					
					console.log(" "+r+" - " + px[r].name + " ("+px[r].id+")");										
				}	
								
				var standard_input = process.stdin;
				standard_input.setEncoding('utf-8');
				standard_input.on('data', function (data) {
										
				var selPrx=parseInt(data);
					
					
					if(isNaN(selPrx) || selPrx>pxCnt)
					{
						console.log('Pick only one of the selected numbers and hit enter');
						 return
					} else {
						//Stop reading input
						process.stdin.pause();
						console.log("Processing proxy..."+px[selPrx].name);
						getProxyProp(px[selPrx].id);
					}						
				});	
			}							
		}
	});
}	

}

//Get Proxy properties
function getProxyProp(pid) {

	options.uri = 'https://' + hostname + ':4242/qrs/ProxyService/' + pid + '?xrfkey=1234567891234567';
	
	request(options, function (error, response, body) {
		if(error){
			console.log("Error: " + error);
		}
		else{
				
			setCustomForms(body);
			
		}
	});

};

//Update forms
function setCustomForms(body){

//set new base64 encoded forms in Proxy properties structure
if(isRestore){
	body.settings.formAuthenticationPageTemplate = "";
	body.settings.loggedOutPageTemplate = "";
	body.settings.errorPageTemplate = "";
} else {
	var login_form_file = ".\\login_custom.html"; //file will be base64 encoded by this script!
	var logout_form_file = ".\\logout_custom.html"; //file will be base64 encoded by this script!
	var error_form_file = ".\\error_custom.html"; //file will be base64 encoded by this script!
	var login_form = fs.readFileSync(login_form_file);
	var logout_form = fs.readFileSync(logout_form_file);
	var error_form = fs.readFileSync(error_form_file);
	body.settings.formAuthenticationPageTemplate = Buffer.from(login_form).toString('base64');
	body.settings.loggedOutPageTemplate = Buffer.from(logout_form).toString('base64');
	body.settings.errorPageTemplate = Buffer.from(error_form).toString('base64');
	
}

options.method = 'PUT';
options.body = body;

request(options, function (error, response, body) {
	if(error){
		console.log("Error: " + error);
	}
	else{			
		for (prop in body.settings){ 
				if (prop=="virtualProxies"){
					console.log(prop);			
					console.log(body.settings[prop]);						
				}
				if (prop=="formAuthenticationPageTemplate"){ 
					console.log(prop);
					console.log('\x1b[33m%s\x1b[0m', body.settings[prop].substr(0,100));  //yellow
									
					
				}
			}
		if(isRestore){
			console.log('\x1b[36m%s\x1b[0m',"*************** ORIGINAL login, logout and error forms restored ***************");
			
		} else {
			console.log('\x1b[36m%s\x1b[0m',"*************** CUSTOM login, logout and error forms SET ***************");			
		}
		
		
	
	}
});	

}
`

domain

Leave the domain fixed, so you do not have to enter every login, is it possible?

Setup problems

Hello kreta99,
I am facing trouble setting up your extension. I have downloaded node.js with all the modules,...
How do I tell Qlik that it should boot with the custom form? Do I have to run the script in order to use it or can I implement it in Qlik so it starts automatically?

Buffer()

node : (node:7204) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please
use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Excute Command "node custom_forms" Is not able to take the Var Request

Hi,
I have followed all the steps provided In the Page but the "node custom_forms" command Is unable to take the Var Request " Cannot find Module Request "

Module.js: 549 Throw Err;

We are stuck here after completing all the process can you please help us to resolve the Issue.

Thank you,
Neel

Might not work in multinode environments, obsolete buffer

In some environments it takes the same proxy only everytime regardless of from which proxy it is actually installed. Applying loop works in some cases, it seems hardcoding of id of the proxy can be used in emeregencies. Also buffer seems to be obsolete...

//set new base64 encoded forms in Proxy properties structure
	body.settings.formAuthenticationPageTemplate = Buffer.from(login_form).toString('base64');
	body.settings.loggedOutPageTemplate = Buffer.from(logout_form).toString('base64');
	body.settings.errorPageTemplate = Buffer.from(error_form).toString('base64');

Processing multiple proxies

	for (pid in body){
		var proxyid = body[pid].id;	
	
		options.uri = 'https://' + hostname + ':4242/qrs/ProxyService/' + proxyid + '?xrfkey=1234567891234567';
		
		request(options, function (error, response, body) {
			if(error){
				console.log("Error: " + error);
			}
			else{
					
				setCustomForms(body);
				//console.log("Set for proxy:"+proxyid);
			}
		});
	}

Hardcoded id for emergency cases when nothing else works

function getProxyProp(body) {
			var proxyid = "27402a61-2364-4edc-a0b3-07477169d119";//proxy id for emergencies when nothing else works body[0].id;
	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.