Middleware

object Middleware
Companion:
class
trait Sum
trait Mirror
class Object
trait Matchable
class Any

Type members

Classlikes

object Control
Companion:
class
sealed trait Control[+State]
Companion:
object
final class Interceptor1[S](val dummy: Boolean) extends AnyVal
class Interceptor2[S, R, I, O](spec: MiddlewareSpec[I, O], incoming: I => ZIO[R, Nothing, Control[S]])

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from:
Mirror

The name of the type

The name of the type

Inherited from:
Mirror

Value members

Concrete methods

Sets cookie in response headers

Sets cookie in response headers

def addCookieZIO[R](cookie: ZIO[R, Nothing, Cookie[Response]]): Middleware[R, Unit, Cookie[Response]]
final def basicAuth(f: Credentials => Boolean)(implicit trace: Trace): Middleware[Any, String, Unit]

Creates a middleware for basic authentication

Creates a middleware for basic authentication

final def basicAuth(u: String, p: String)(implicit trace: Trace): Middleware[Any, String, Unit]

Creates a middleware for basic authentication that checks if the credentials are same as the ones given

Creates a middleware for basic authentication that checks if the credentials are same as the ones given

def basicAuthZIO[R](f: Credentials => ZIO[R, Nothing, Boolean])(implicit trace: Trace): Middleware[R, String, Unit]

Creates a middleware for basic authentication using an effectful verification function

Creates a middleware for basic authentication using an effectful verification function

final def bearerAuth(f: String => Boolean)(implicit trace: Trace): Middleware[Any, String, Unit]

Creates a middleware for bearer authentication that checks the token using the given function

Creates a middleware for bearer authentication that checks the token using the given function

Value parameters:
f

: function that validates the token string inside the Bearer Header

final def bearerAuthZIO[R](f: String => ZIO[R, Nothing, Boolean])(implicit trace: Trace): Middleware[R, String, Unit]

Creates a middleware for bearer authentication that checks the token using the given effectful function

Creates a middleware for bearer authentication that checks the token using the given effectful function

Value parameters:
f

: function that effectfully validates the token string inside the Bearer Header

Creates a middleware for Cross-Origin Resource Sharing (CORS).

Creates a middleware for Cross-Origin Resource Sharing (CORS).

See also:
final def csrfGenerate[R, E](tokenName: String, tokenGen: ZIO[R, Nothing, String])(implicit trace: Trace): Middleware[R, Unit, Cookie[Response]]

Generates a new CSRF token that can be validated using the csrfValidate middleware.

Generates a new CSRF token that can be validated using the csrfValidate middleware.

CSRF middlewares: To prevent Cross-site request forgery attacks. This middleware is modeled after the double submit cookie pattern. Used in conjunction with csrfValidate middleware.

https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie

Validates the CSRF token appearing in the request headers. Typically the token should be set using the csrfGenerate middleware.

Validates the CSRF token appearing in the request headers. Typically the token should be set using the csrfGenerate middleware.

CSRF middlewares : To prevent Cross-site request forgery attacks. This middleware is modeled after the double submit cookie pattern. Used in conjunction with csrfGenerate middleware

https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie

def customAuth[R, I](headerCodec: HeaderCodec[I])(verify: I => Boolean): Middleware[R, I, Unit]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app.

def customAuthZIO[R, I](headerCodec: HeaderCodec[I], responseHeaders: Headers, responseStatus: Status)(verify: I => ZIO[R, Nothing, Boolean])(implicit trace: Trace): Middleware[R, I, Unit]

Creates an authentication middleware that only allows authenticated requests to be passed on to the app using an effectful verification function.

Creates an authentication middleware that only allows authenticated requests to be passed on to the app using an effectful verification function.

def fromFunction[A, B](spec: MiddlewareSpec[A, B])(f: A => B): Middleware[Any, A, B]
def fromFunctionZIO[R, A, B](spec: MiddlewareSpec[A, B])(f: A => ZIO[R, Nothing, B]): Middleware[R, A, B]
def intercept[S, R, I, O](spec: MiddlewareSpec[I, O])(incoming: I => Control[S])(outgoing: (S, Response) => O): Middleware[R, I, O]

Concrete fields

val none: Middleware[Any, Unit, Unit]