Class: Rack::Webauth::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/rack-webauth.rb

Overview

Detects & provides webauth related information conveniently from the rack environment.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Info) initialize(env)

Read webauth from given environment. Most information (e.g. attributes, privgroups) will be read on demand, though.



88
89
90
91
92
93
94
# File 'lib/rack-webauth.rb', line 88

def initialize(env)
  @env = env
  @login = (env["WEBAUTH_USER"] || env["REMOTE_USER"])
  @logged_in = (@login && @login.any? && @login != ANONYMOUS)
  # reset login if it was "" or ANONYMOUS
  @login = nil unless @logged_in
end

Instance Attribute Details

- (Object) login (readonly)

Returns the value of attribute login



81
82
83
# File 'lib/rack-webauth.rb', line 81

def 
  @login
end

Instance Method Details

- (Object) attributes

attributes passed via mod_webauthldap.

webauth.stanford.edu/manual/mod/mod_webauthldap.html#webauthldapattribute

See detect_attributes for details.



101
102
103
# File 'lib/rack-webauth.rb', line 101

def attributes
  @attributes ||= detect_attributes
end

- (Object) authrule

Rule ("Require" statement) that authenticated this user

webauth.stanford.edu/manual/mod/mod_webauthldap.html#webauthldapauthrule



117
118
119
# File 'lib/rack-webauth.rb', line 117

def authrule
  @authrule ||= env['WEBAUTH_LDAPAUTHRULE']
end

- (Boolean) logged_in?

explains itself.

Returns:

  • (Boolean)


83
# File 'lib/rack-webauth.rb', line 83

def logged_in? ; @logged_in ; end

- (Object) privgroup

privgroup of the user.

webauth.stanford.edu/manual/mod/mod_webauthldap.html#webauthldapprivgroup

TOOD: implement detection of multiple privgroups



110
111
112
# File 'lib/rack-webauth.rb', line 110

def privgroup
  @privgroup ||= env['WEABUTH_LDAPPRIVGROUP']
end

- (Object) token_creation

Time when the authentication cookie was created.

webauth.stanford.edu/manual/mod/mod_webauth.html#sectionenv

Also see: token_expiration, token_lastused



126
127
128
# File 'lib/rack-webauth.rb', line 126

def token_creation
  Time.at(env["WEBAUTH_TOKEN_CREATION"].to_i) if env.key?("WEBAUTH_TOKEN_CREATION")
end

- (Object) token_expiration

Time when the authentication cookie will expire. This isn't authorative, as WebAuthInactiveExpire may be set.

webauth.stanford.edu/manual/mod/mod_webauth.html#sectionenv

Also see: token_creation, token_lastused



136
137
138
# File 'lib/rack-webauth.rb', line 136

def token_expiration
  Time.at(env["WEBAUTH_TOKEN_EXPIRATION"].to_i) if env.key?("WEBAUTH_TOKEN_EXPIRATION")
end

- (Object) token_lastused

Time the authentication cookie was last used. Only present is WebAuthLastUseUpdateInterval is set.

webauth.stanford.edu/manual/mod/mod_webauth.html#webauthlastuseupdateinterval

Also see: token_creation, token_expiration



146
147
148
# File 'lib/rack-webauth.rb', line 146

def token_lastused
  Time.at(env["WEBAUTH_TOKEN_LASTUSED"].to_i) if env.key?("WEBAUTH_TOKEN_LASTUSED")
end