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.

See README and Rack::Webauth::Helpers for usage information & examples.

Defined Under Namespace

Classes: NotAvailable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Info

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


111
112
113
114
115
116
117
# File 'lib/rack-webauth.rb', line 111

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

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env


104
105
106
# File 'lib/rack-webauth.rb', line 104

def env
  @env
end

#loginObject (readonly)

Returns the value of attribute login


103
104
105
# File 'lib/rack-webauth.rb', line 103

def 
  @login
end

Instance Method Details

#attributesObject

attributes passed via mod_webauthldap.

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

See detect_attributes for details.


124
125
126
# File 'lib/rack-webauth.rb', line 124

def attributes
  @attributes ||= detect_attributes
end

#authruleObject

Rule (“Require” statement) that authenticated this user

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


140
141
142
# File 'lib/rack-webauth.rb', line 140

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

#logged_in?Boolean

explains itself.

Returns:

  • (Boolean)

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

def logged_in? ; @logged_in ; end

#privgroupObject

privgroup of the user.

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

TOOD: implement detection of multiple privgroups


133
134
135
# File 'lib/rack-webauth.rb', line 133

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

#token_creationObject

Time when the authentication cookie was created.

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

Also see: token_expiration, token_lastused


149
150
151
# File 'lib/rack-webauth.rb', line 149

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

#token_expirationObject

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


159
160
161
# File 'lib/rack-webauth.rb', line 159

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

#token_lastusedObject

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


169
170
171
# File 'lib/rack-webauth.rb', line 169

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