RoutesBuilder
-
Adds Flexible Auth to a route. This route can be accessed without a token (while not logged in), but
req.auth.get(User.self)
will still return a user if one is logged in. Route handlers for these routes should not callreq.auth.require(User.self)
. A route with no auth middleware will not auth any user and.get(User.self)
will always return nil. The Basic and Token auth groups will throw an error if no user gets authenticated (specifically:User.guardMiddleware
throws).So, use this auth group for routes that can be accessed while not logged in, but which provide more (or different) data when a logged-in user accesses the route.
Declaration
Swift
func addFlexAuth() -> RoutesBuilder
-
For routes that require HTTP Basic Auth. Tokens won’t work. Generally, this is only for the login route.
Declaration
Swift
func addBasicAuthRequirement() -> RoutesBuilder
-
For routes that require a logged-in user. Applying this auth group to a route will make requests that don’t have a valid token fail with a HTTP 401 error.
Declaration
Swift
func addTokenAuthRequirement() -> RoutesBuilder
-
Declaration
Swift
func flexRoutes(feature: SwiftarrFeature? = nil, path: PathComponent...) -> RoutesBuilder
-
Declaration
Swift
func tokenRoutes(feature: SwiftarrFeature? = nil, minAccess: UserAccessLevel = .banned, path: PathComponent...) -> RoutesBuilder