Sha256: b5b844b30b19dd5442efafd29ccc655c06ae0181d8d8356305624d81e9ffe982
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
require 'omniauth' require 'rkerberos' module OmniAuth module Strategies class Krb5 include OmniAuth::Strategy args [:realm] option :title, "Kerberos Authentication" def initialize( app, *args, &block ) super @krb5 = Kerberos::Krb5.new @krb5.set_default_realm(options.realm) end def request_phase OmniAuth::Form.build(:title => options.title, :url => callback_path) do text_field 'Username', 'username' password_field 'Password', 'password' end.to_response end def callback_phase begin return fail!(:invalid_credentials) unless username && password @krb5.get_init_creds_password(username_with_realm, password) super rescue Exception => e return fail!(:invalid_credentials, e) ensure @krb5.close end end uid do username_with_realm end info do { :name => username } end def realm @krb5.get_default_realm end protected def username_with_realm user_with_realm = username.dup user_with_realm += "@#{realm}" unless username.include?('@') end def username request['username'] end def password request['password'] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-krb5-0.0.1 | lib/omniauth/strategies/krb5.rb |