GuardedBy

io.eezo.auth.GuardedBy
final class GuardedBy[A, U] extends Guarded[A]

What a guard's required, only and except answer: the declaration a model writes, still holding the guard that made it.

A io.eezo.http.Guarded and nothing more as far as every existing call site can tell, which is why given Guarded[Post] = User.guard.required still says exactly what it said. The one thing it adds is owning, and it can add it only because it still knows who the guard says is behind a request, its currentUser: a plain Guarded has a Route => Route and no way back to the user, so ownership could not be chained onto one.

Value parameters

currentUser

who is signed in, as the key that a row's owner field holds, and nobody when the request carries no live sign in. Read out of the session rather than through the guard's find, because a covered route is a guarded route and the wrapper already looked the user up before the handler ran; a second lookup per request would buy nothing.

identify

the guard's own naming, handed on to Guarded and read by nothing here; see io.eezo.http.Guarded.identify.

Attributes

Source
Owning.scala
Graph
Supertypes
class Guarded[A]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

inline def owning(inline selector: A => Id[U]): Owning[A, U]

Which field of the model records its owner, written as a selector so the compiler checks it.

Which field of the model records its owner, written as a selector so the compiler checks it.

inline, because the field's name is what db renders into the owner condition of four statements, and the only place that name exists as something a compiler can check is the selector's own tree. Read at compile time it is the model's field; typed by hand it is a string that is right until somebody renames the field.

The body calls owningField and reaches nothing private, which is what an inline method expanded in a user's companion object is allowed to do.

Attributes

Source
Owning.scala
def owningField(name: String, get: A => Id[U]): Owning[A, U]

owning's body, after the selector has given up its name.

owning's body, after the selector has given up its name.

Public only because an inline method's expansion has to be able to call it from wherever the declaration is written. A caller who writes the name by hand gets what they asked for, which is the thing owning exists to make unnecessary.

Attributes

Source
Owning.scala

Inherited methods

def mounting(route: Route): Seq[Route]

What one handwritten route becomes in the table: the guard's own pages, and that route wrapped.

What one handwritten route becomes in the table: the guard's own pages, and that route wrapped.

A handwritten route has no Action, so there is nothing to test actions against and the wrapper reaches it directly. A page is guarded or it is public, which is the same rule Guarded[Index.type] = Guarded.public states in the other direction, and public wraps nothing and carries nothing, so an unguarded application's table is exactly what it was.

The login page comes out of every declaration rather than being mounted once somewhere else, because the two have to arrive together: a route that redirects to a page nobody mounted is a 404 at the end of every refusal. The table takes distinct afterwards, which is safe only because one guard builds its routes once and hands the same instances to every declaration it makes.

Attributes

Inherited from:
Guarded
Source
Guarded.scala

Concrete fields

val currentUser: Request => Option[Id[U]]

Attributes

Source
Owning.scala