works.iterative.server.http

Members list

Type members

Classlikes

Error handler for authentication and authorization failures.

Error handler for authentication and authorization failures.

This object provides HTTP4S response mapping for AuthenticationError enum variants. It ensures consistent error responses across the application:

  • Unauthenticated → 401 Unauthorized
  • Forbidden → 403 Forbidden
  • InvalidCredentials → 401 Unauthorized
  • TokenExpired → 401 Unauthorized
  • InvalidToken → 401 Unauthorized

Usage in HTTP routes:

 service.updateDocument(id, title)
   .mapError {
     case e: AuthenticationError => AuthErrorHandler.toResponse(e)
   }

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait AuthedZIOWebModule[R, C] extends WebModuleTypes

Authenticated web module is similar to ZIOWebModule, but it requires additional Context type parameter. This type parameter is used by the authentication system to provide additional information about the authenticated user.

Authenticated web module is similar to ZIOWebModule, but it requires additional Context type parameter. This type parameter is used by the authentication system to provide additional information about the authenticated user.

To convert AuthedZIOWebModule to ZIOWebModule, you will need to provide authentication middleware, e.g. by using pac4j:

trait Pac4jZIOWebModule[R](pac4jSecurity: Pac4jHttpSecurity[R]) extends ZIOWebModule[R]:
   def wrap[C](inner: AuthedZIOWebModule[R, C])(
       toContext: List[CommonProfile] => Option[C],
       clients: Option[String] = Some("OidcClient")
   ): ZIOWebModule[R]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Factory that creates the appropriate AuthenticationService based on configuration.

Factory that creates the appropriate AuthenticationService based on configuration.

Reads auth_provider and env from ZIO Config to determine which authentication implementation to use:

  • "test": TestAuthenticationService (for testing only, forbidden in production)
  • "oidc": Pac4jAuthenticationAdapter (for production OIDC authentication)

Example usage:

 val app = ZIO.serviceWithZIO[AuthenticationService](_.currentUser)
   .provide(AuthenticationServiceFactory.layer)

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait DslSupport

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class HttpApplication[Env](secureEndpoints: List[ZServerEndpoint[Env & CurrentUser, ZioStreams]], publicEndpoints: List[ZServerEndpoint[Env, ZioStreams]], wsEndpoints: List[ZServerEndpoint[Env, ZioStreams & WebSockets]] = ...)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait HttpServer

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object HttpServer

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
HttpServer.type
trait ModuleRegistry[R]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Pac4jModuleRegistry[R, U]
Self type

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
final case class SPAConfig(appPath: String = ..., appIndex: String = ..., filePath: Option[String] = ..., resourcePath: String = ...)

Configuration for the single page application (SPA) endpoints.

Configuration for the single page application (SPA) endpoints.

By default, the application will be served from prefix/app path, static resources from prefix/? path.

Under "app", only index.html will be served.

As this has a catch-all route, it should be the last route in the list.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SPAConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
SPAConfig.type
class SPAEndpoints[Env](config: SPAConfig)

Attributes

Supertypes
class Object
trait Matchable
class Any
class ScalatagsViteSupport(entrypoints: PartialFunction[String, Entries]) extends ViteSupport[Seq[Modifier]]

Attributes

Companion
object
Supertypes
trait ViteSupport[Seq[Modifier]]
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait ViteSupport[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait WebFeatureModule[F[_]]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ZIOWebModule[R]

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait AuthedZIOWebModule[R, C]
trait ZIOWebModule[R]
trait ZIOWebModule[R] extends WebFeatureModule[[A] =>> RIO[R, A]], WebModuleTypes

Attributes

Companion
object
Supertypes
trait WebFeatureModule[[A] =>> RIO[R, A]]
class Object
trait Matchable
class Any
object ZIOWebModule

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type