I have jsp/struts application need to upgrade.
Currently we only have 1 websystem(branch) and now I need to upgrade and build another websystem that represent HQ. HQ and branches are different domain. HQ can see 4 branches in the HQ page. We need to login to access HQ and branches. If HQ want to see the details in branch A, we can click on the link such as
Total attack : <a href="https://www.branch_A.com/xxx/sss/?sss=333">105</a>
My Question is how to protect the URL so that the communication can only be done by HQ and branch_A.com server securely? If we use that URL from another IP it should display unauthorized message.
I have done to control the IP using request.getRemoteAddr() in the branch but it is not enough secured.
Can anyone help me to give ideas on how to protect this url?
So you already have a login system. As you’re already asking this question, it sounds like a homegrown login system, otherwise you could just have configured the container managed authentication to check certain url-patterns for any logged-in users/roles.
You basically just need to check the logged-in user whenever specific url-patterns are been requested. A Filter is perfectly suitable for this. Let’s assume that your homegrown login system puts the logged-in user in the session scope, the Filter then just need to test its presence:
Map this Filter in
web.xmlon anurl-patternmatching the requests you’d like to be filtered on the logged-in user. You can even go a step further by adding an user role and if the logged-in user has the right role to visit the URL.