Module: Katalyst::Basic::Auth

Defined in:
lib/katalyst/basic/auth.rb,
lib/katalyst/basic/auth/rails.rb,
lib/katalyst/basic/auth/config.rb,
lib/katalyst/basic/auth/middleware.rb

Defined Under Namespace

Classes: Config, Middleware, Railtie

Class Method Summary collapse

Class Method Details

.add(path, username: nil, password: nil, ip_allowlist: nil) ⇒ Object

Add a path to be protected by basic authentication

Parameters:

  • path (String)

    Relative path

  • username (String) (defaults to: nil)

    Basic auth user name

  • password (String) (defaults to: nil)

    Basic auth password

  • ip_allowlist (Array<String>) (defaults to: nil)

    List of IP addresses or network ranges to allow without basic auth



16
17
18
19
20
21
22
# File 'lib/katalyst/basic/auth.rb', line 16

def add(path, username: nil, password: nil, ip_allowlist: nil)
  Config.add(path:         path,
             username:     username,
             password:     password,
             enabled:      true,
             ip_allowlist: ip_allowlist)
end

.exclude(path) ⇒ Object

Add a path to be excluded from basic authentication

Parameters:

  • path (String)

    Relative path



26
27
28
# File 'lib/katalyst/basic/auth.rb', line 26

def exclude(path)
  Config.add(path: path, enabled: false)
end