Authentication with Servlet

I am trying to authenticate users using a servlet module I created.
I want to allow users with certain IP Addresses configured via my plugin to bypass the login page and go straight into the application.

Does this make sense? And how can I go around implementing the logic

Thanks