Class: Hobix::BaseFacet
- Inherits:
-
BasePlugin
- Object
- BasePlugin
- Hobix::BaseFacet
- Defined in:
- lib/hobix/base.rb
Overview
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.
Direct Known Subclasses
API, Facets::Comments, Facets::Publisher, Facets::Trackbacks, Facets::WikiEdit
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BasePlugin
Class Method Details
.not_found(app) ⇒ Object
166 167 168 |
# File 'lib/hobix/base.rb', line 166 def self.not_found app app.send_not_found "Action `#{ app.action_uri }' not found. If this address should work, check your plugins." end |
Instance Method Details
#protect(app, weblog) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/hobix/base.rb', line 169 def protect app, weblog auth = ENV['HTTP_AUTHORIZATION'] || ENV['X-HTTP_AUTHORIZATION'] if auth realm = 'Hobix login' auth_type, auth = auth.split ' ', 2 = false case auth_type.downcase when 'basic' require 'base64' name, pass = Base64::decode64( auth.strip ).split ':', 2 = weblog. name, pass when 'digest' require 'md5' opts = {} auth.gsub( /(\w+)="(.*?)"/ ) { opts[$1] = $2 } app.puts opts.inspect end return true if end app. # nonce = ["#{ Time.now.to_f }:#{ app.action_uri }"].pack("m").gsub /\s/, '' # app.set_header 'WWW-Authenticate', %{Digest qop="auth", realm="#{ realm }", nonce="#{ nonce }", algorithm="MD5"} app.set_header 'WWW-Authenticate', %{Basic realm="#{ realm }"} false end |