User login with external function


Currently I have implemented my function for login which include PAM,
Freradius and another type of authentication.
I have my module:

LoadModule restconf_module /
<Location /restconf>
SetHandler restconf

And now my settings is Require all granted.

I get all request to my module and in handler function I call my function
for check login.

I want to implement my login function outside my module because all
requests call my login function and I want to optimize it.

Can i call my login function from other modules etc. mod_session?


Best regards,