Class Hobix::BaseFacet
In: lib/hobix/base.rb
Parent: BasePlugin

The BaseFacet plugin is the superclass for all plugins which have an interface (CGI, UI, etc.) These interfaces expose some functionality to the user through an entry form or series of views.

Methods

not_found   protect  

Public Class methods

[Source]

     # File lib/hobix/base.rb, line 166
166:     def self.not_found app
167:         app.send_not_found "Action `#{ app.action_uri }' not found.  If this address should work, check your plugins."
168:     end

Public Instance methods

[Source]

     # File lib/hobix/base.rb, line 169
169:     def protect app, weblog
170:         auth = ENV['HTTP_AUTHORIZATION'] || ENV['X-HTTP_AUTHORIZATION']
171:         if auth
172:             realm = 'Hobix login'
173:             auth_type, auth = auth.split ' ', 2
174:             authorized = false
175:             case auth_type.downcase
176:             when 'basic'
177:                 require 'base64'
178:                 name, pass = Base64::decode64( auth.strip ).split ':', 2
179:                 authorized = weblog.authorize name, pass
180:             when 'digest'
181:                 require 'md5'
182:                 opts = {}
183:                 auth.gsub( /(\w+)="(.*?)"/ ) { opts[$1] = $2 }
184:                 app.puts opts.inspect
185:             end
186:             return true if authorized
187:         end
188: 
189:         app.send_unauthorized
190:         # nonce = ["#{ Time.now.to_f }:#{ app.action_uri }"].pack("m").gsub /\s/, ''
191:         # app.set_header 'WWW-Authenticate', %{Digest qop="auth", realm="#{ realm }", nonce="#{ nonce }", algorithm="MD5"}
192:         app.set_header 'WWW-Authenticate', %{Basic realm="#{ realm }"}
193:         false
194:     end

[Validate]