module KerberosAuthenticator::Krb5

An FFI wrapper around the Kerberos 5 library. Use the environmental variable FFI_KRB5_LIBRARY_NAME to override the library loaded.

Constants

PREFERRED_VERSIONS

Version suffixes of the library to search for, in order:

  • .3: MIT as of Debian 8, RHEL 7

  • .26: Heimdal as of Debian 8, RHEL 7

and then no suffix (which should pickup OS X Kerberos).

Public Class Methods

attach_function(c_name, params, returns, options = {}) click to toggle source

Attaches a Kerberos library function to Krb5. Extends FFI's built-in method to:

@api private @see www.rubydoc.info/github/ffi/ffi/FFI/Library#attach_function-instance_method FFI::Library#attach_function

Calls superclass method
# File lib/kerberos_authenticator/krb5/attach_function.rb, line 9
def self.attach_function(c_name, params, returns, options = {})
  ruby_name = c_name.to_s.gsub(/^krb5_/, '').to_sym

  super(ruby_name, c_name, params, returns, options)

  if returns == :krb5_error_code
    no_check_name = "#{ruby_name}_without_catching_error"

    alias_method(no_check_name, ruby_name)

    if params.first == :krb5_context
      define_method(ruby_name) do |*args, &block|
        Krb5::LibCallError.raise_if_error(args.first) { public_send(no_check_name, *args, &block) }
      end
    else
      define_method(ruby_name) do |*args, &block|
        Krb5::LibCallError.raise_if_error(nil) { public_send(no_check_name, *args, &block) }
      end
    end

    module_function no_check_name
  end

  module_function ruby_name
end
use_secure_context() click to toggle source
# File lib/kerberos_authenticator/krb5.rb, line 28
def self.use_secure_context
  @use_secure_context
end
use_secure_context=(v) click to toggle source
# File lib/kerberos_authenticator/krb5.rb, line 32
def self.use_secure_context=(v)
  @use_secure_context = v
end