Base solution for your next web application
From Nov 21
To Dec 1
Also valid for the
existing customers!
Open Closed

Validating each request for authorization for validating IP Address #10350

demo.solaru created

ASPNETZERO 7.0.0, Angular, .Net Code

Question(this is not a issue ticket): We are trying to implement IP validation on each request, and wanted to know how I can extend the Authorization so validate each request based on our business logic. I thought of implementaing when they login, but as we have SPA: once user login and change their IP address and now they can access application from IP restrictrictions.

Any help would be appriciated. Thanks!

1 Answer(s)
  • 0
    musa.demir created

    Hi @demo.solaru*

    You can create an action filter to check clients ip address and return unauthorized exception with specific message. Then to let authorized users to change their ip address you can create an enpoint which is not controlled by that ip address filter. Than if any request get an unauthorized exception with ip address message you can call ip changing endpoint, and if user authorized, you can change their stoed ip address.

    See an example to create action filter: (You should store that ip addresses in db not appsettings.json)