Custom login page for Arcgis Server service based authorization

337
1
03-11-2022 03:05 AM
muygunol
New Contributor II

Hi, 

We are using non federted Arcgis Server 10.6 and using Windows AD as User Store.

Our login usernames like domain\username

With our web applications created by Web App Builder, we want to use username without domain prefix in esri sign in dialog box.

We can generate tokens with Arcgis Server Token Service with post metod.

As i can see web application calls secured web services by addining this token at the end of the service adress while loading web map.

İ want to build a custom login screen, users input their identity data then by using post with domain prefix i will get token for secured services and redirect to web app builder application.
But how to use this token with web application on the redirected page to bypass esri identity manager?
Thanks...


Arcgis Gis Server 10.6
Server Security
User Store: Windows Domain
Role Store:ArcGIS Server Built-in
Authentication Tier:GIS Server
Authentication Mode:ArcGIS Tokens

0 Kudos
1 Reply
muygunol
New Contributor II

By modifying init.js i succesfully generate token and register it.

Only i must modify a login screen while web app loads.
İ am trying to put a user logon on web app index.html, but unsuccesfull for now.

 

const loginForm = document.getElementById("login-form");
const loginButton = document.getElementById("login-form-submit");
const loginErrorMsg = document.getElementById("login-error-msg");

loginButton.addEventListener("click", (e) => {e.preventDefault();
const username = loginForm.username.value;
const password = loginForm.password.value;

require(["esri/IdentityManager","dojo/domReady!"], function(IdentityManager) {


if (loginForm.username.value.includes("domainprefix\\")) {
var username = (loginForm.username.value);
} else {var username = ("domainprefix\\" + loginForm.username.value);};

var password = loginForm.password.value;
var tokenvalue = $.ajax({
type: "POST",
url: "https://domain/arcgis/tokens/generateToken",
data: {
username: username,
password: password,
client: "requestip",
expiration: '60',
f: "json"
},
dataType: "json"
});

if (tokenvalue) {
tokenvalue
.success(function (response){
if (response.token) {

IdentityManager.registerToken({
server: "https://domain/arcgis/rest/services",
token: response.token
});
console.log("TOKEN=" ,response.token);
}
}).error(function(err) {
console.log("operation failed err:" + err);
});
}
});
});

 

 


0 Kudos