Idira Identity: How to block user access to an application from an specific IP address or several IP addresses

Idira Identity: How to block user access to an application from an specific IP address or several IP addresses

88
Created On 11/10/26 11:03 AM - Last Modified 11/10/26 12:58 PM


Question


Is there a way to block user from a specific IP or several IP addresses when accessing an application?

Environment


Identity App Access Service

Answer


This can be done by editing the application policy script for the application to be restricted. To get started, log in to the Admin Portal and select the desired app from the list of Web Apps. After opening the app settings, select Policy and edit the script with the below example.

Note: IP ranges cannot be defined in the script.

if(context.ipAddress == 'XX.XXX.XX.123'){             
trace("allowed ip");       
policy.Locked = false;
}  
else{     
trace("non-allowed ip");              
policy.Locked = true;     
}             
}             


If a number of IP addresses need to be blocked, the following script can be used instead:

var ipArray = ['XX.XXX.XX.24', 'XX.XXX.XX.335', 'XX.XXX.XX.183'];
if(ipArray.indexOf(context.ipAddress) >= 0){
trace("allowed ip");
policy.Locked = false;
}
else{
trace("non-allowed ip");
policy.Locked = true;
}
}


Additional Information


Details

Question:

Is there a way to block user from a specific IP or several IP addresses when accessing an application?



Answer:

This can be done by editing the application policy script for the application to be restricted. To get started, log in to the Admin Portal and select the desired app from the list of Web Apps. After opening the app settings, select Policy and edit the script with the below example.

Note: IP ranges cannot be defined in the script.

if(context.ipAddress == 'XX.XXX.XX.123'){             
trace("allowed ip");       
policy.Locked = false;
}  
else{     
trace("non-allowed ip");              
policy.Locked = true;     
}             

}             

If a number of IP addresses need to be blocked, the following script can be used instead:


var ipArray = ['XX.XXX.XX.24', 'XX.XXX.XX.335', 'XX.XXX.XX.183'];
if(ipArray.indexOf(context.ipAddress) >= 0){
trace("allowed ip");
policy.Locked = false;
}
else{
trace("non-allowed ip");
policy.Locked = true;
}
}



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000001GAzCAM&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail