Authly::Handler::RequireScope
Inherits HTTP::Handler < Reference < Object
Lets a request through only when the token Bearer verified grants the scopes: all of
all and at least one of any (an empty list asks nothing). Otherwise 403 insufficient_scope
with the required scopes in the challenge; without verified claims (no Bearer before it)
the request is refused with 401, never let through.
users = Authly::Handler::RequireScope.all("read:users", prefixes: ["/users"])
admin = Authly::Handler::RequireScope.any("admin", "root", prefixes: ["/admin"])
Applies to every path unless narrowed (`prefixes:` is an allowlist, `except:` lists open paths);
see `PathFilter`. With `pass_preflight: true` it lets CORS preflights through like `Bearer` does,
and the same caution applies.
HTTP::Server.new([bearer, users, admin, app])
Constructors
all(*scopes : String, realm : String = "authly", prefixes : Array(String) | Nil = nil, except : Array(String) = [] of String, except_exact : Array(String) = [] of String, pass_preflight : Bool = false) : RequireScope
Sourceany(*scopes : String, realm : String = "authly", prefixes : Array(String) | Nil = nil, except : Array(String) = [] of String, except_exact : Array(String) = [] of String, pass_preflight : Bool = false) : RequireScope
Sourcenew(all : Array(String) = [] of String, any : Array(String) = [] of String, realm : String = "authly", prefixes : Array(String) | Nil = nil, except : Array(String) = [] of String, except_exact : Array(String) = [] of String, pass_preflight : Bool = false)
SourceInstance methods
call(context : HTTP::Server::Context)
Sourcerealm
Source