Module: Mutx::Authentication

Defined in:
lib/mutx/lib/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'lib/mutx/lib/authentication.rb', line 5

def authenticate?
  basic_auth(env) do |user, pass|
    user == "mutx" && pass == "mutxAdmin"
  end
end

#with_authenticationObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mutx/lib/authentication.rb', line 11

def with_authentication()
  if authenticate?
  	yield
  else
  	on default do
       res.status = 401
      res.headers["WWW-Authenticate"] = 'Basic realm="MutxApp"'
      res.write "Access Denied, Mutx don't let you go to that place without authorization"
    end
  end
end