Method: Narou::AppServer#setup_server_authentication

Defined in:
lib/web/appserver.rb

#setup_server_authenticationObject

サーバーの認証の設定とりあえずDigest認証のみ



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/web/appserver.rb', line 166

def setup_server_authentication
  auth = Inventory.load("global_setting", :global).group("server-digest-auth")
  user = auth.user
  hashed = auth.hashed_password
  passwd = hashed || auth.password

  # enableかつユーザー名とパスワードが設定されている時のみ認証を有効にする
  return unless auth.enable && user && passwd

  self.class.class_exec do
    use Rack::Auth::Digest::MD5, { realm: "narou.rb", opaque: "", passwords_hashed: hashed } do |username|
      passwd if username == user
    end
  end
end