Sha256: aab4676ccc5784bbde825a4616830ab3a2ebc95831bc0dd629a4b586b07cd50e
Contents?: true
Size: 771 Bytes
Versions: 19
Compression:
Stored size: 771 Bytes
Contents
require 'certmeister/policy/response' require 'ipaddr' module Certmeister module Policy class IP def initialize(networks) @networks = networks.map { |n| IPAddr.new(n) } end def authenticate(request) begin if !request[:ip] Certmeister::Policy::Response.new(false, "missing ip") else ip = IPAddr.new(request[:ip]) if @networks.any? { |n| n.include?(ip) } Certmeister::Policy::Response.new(true, nil) else Certmeister::Policy::Response.new(false, "unauthorized ip") end end rescue IPAddr::Error Certmeister::Policy::Response.new(false, "invalid ip") end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems