NestedAuthModifier
public class NestedAuthModifier<
A: AuthEndpoint,
I: CorvusModel,
U: CorvusModelAuthenticatable>:
RestModifier<A>, AuthEndpoint
A class that wraps a component which utilizes an .auth() modifier. Differs
from AuthModifier by authenticating on the user of an intermediate parent
I of A.QuerySubject. Requires an object U that represents the user to
authorize.
-
The
KeyPathto the user property of theQuerySubjectwhich is to be authenticated.Declaration
Swift
public typealias UserKeyPath = KeyPath< I, I.Parent<U> > -
The
KeyPathto the intermediateIof the endpoint’sQuerySubject.Declaration
Swift
public typealias IntermediateKeyPath = KeyPath< A.QuerySubject, A.QuerySubject.Parent<I> > -
The path to the property to authenticate for.
Declaration
Swift
public let userKeyPath: UserKeyPath -
The path to the intermediate.
Declaration
Swift
public let intermediateKeyPath: IntermediateKeyPath -
Initializes the modifier with its underlying
QueryEndpointand itsauthpath, which is the keypath to the property to run authorization for.Declaration
Swift
public init( _ authEndpoint: A, intermediate: IntermediateKeyPath, user: UserKeyPath )Parameters
queryEndpointThe
QueryEndpointwhich the modifer is attached to.intermediateA
KeyPathto the intermediate.userA
KeyPathwhich leads to the property to authenticate for. -
A method which checks if the user
Usupplied in theRequestis equal to the user belonging to the particularQuerySubject.Throws
AnAborterror if an item is not found.Declaration
Swift
override public func handler(_ req: Request) throws -> EventLoopFuture<Element>Parameters
reqAn incoming
Request.Return Value
An
EventLoopFuturecontaining an eagerloaded value as defined byElement. If authorization fails or a user is not found, HTTP.unauthorizedand.notFoundare thrown respectively.
NestedAuthModifier Class Reference