https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43258

--- Comment #6 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 203422
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203422&action=edit
Bug 43258: (follow-up) Add Koha::REST::Plugin::Restrictions

Add a Mojolicious plugin that provides the ip_in_range helper for
REST API controllers. It wraps Koha::IP->is_ip_in_range(), sourcing
the client IP from $c->tx->remote_address (the Mojo equivalent of
$ENV{REMOTE_ADDR}).

Usage in controllers:

    if ( $c->ip_in_range( C4::Context->preference('OpacSuppressionByIPRange') )
) {
        # client is in the exception range
    }

The plugin is registered in Koha::REST::V1 startup alongside the
existing plugins (Pagination, Query, Objects, Exceptions).

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/Koha/REST/Plugin/Restrictions.t
=> SUCCESS: All tests pass
3. Tests verify the helper correctly delegates to Koha::IP using
   the request's remote address (127.0.0.1 from Test::Mojo)
4. Sign off :-D

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to