Skip to content

Commit

Permalink
Cleanup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Nov 14, 2024
1 parent e73f305 commit 5f73732
Showing 1 changed file with 0 additions and 172 deletions.
172 changes: 0 additions & 172 deletions waltid-libraries/auth/waltid-ktor-authnz/docs/new-auth-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,129 +157,6 @@ import org.intellij.lang.annotations.Language
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

fun Route.globalImplicitSingleStep() {
route("global-implicit1") {
@Language("JSON")
val flowConfig = """
{
"method": "userpass",
"ok": true
}
""".trimIndent()
val authFlow = AuthFlow.fromConfig(flowConfig)


val contextFunction: PipelineContext<Unit, ApplicationCall>.() -> AuthContext = {
AuthContext(
tenant = call.request.host(),
sessionId = call.parameters["sessionId"],
implicitSessionGeneration = true,
initialFlow = authFlow
)
}

registerAuthenticationMethod(UserPass, contextFunction)
}
}

fun Route.globalImplicitMultiStep() {
route("global-implicit2") {
@Language("JSON")
val flowConfig = """
{
"method": "userpass",
"continue": [{
"method": "totp",
"ok": true
}]
}
""".trimIndent()
val authFlow = AuthFlow.fromConfig(flowConfig)


val contextFunction: PipelineContext<Unit, ApplicationCall>.() -> AuthContext = {
AuthContext(
tenant = call.request.host(),
sessionId = call.parameters["sessionId"],
implicitSessionGeneration = true,
initialFlow = authFlow
)
}

registerAuthenticationMethod(UserPass, contextFunction)
route("{sessionId}") {
registerAuthenticationMethod(TOTP, contextFunction)
}
}
}

fun Route.globalExplicitMultiStep() {
route("global-explicit2") {
val methods = listOf(UserPass, TOTP)

val contextFunction: PipelineContext<Unit, ApplicationCall>.() -> AuthContext = {
AuthContext(
tenant = call.request.host(),
sessionId = call.parameters["sessionId"] ?: error("Missing sessionId")
)
}

@Language("JSON")
val flowConfig = """
{
"method": "userpass",
"continue": [{
"method": "totp",
"ok": true
}]
}
""".trimIndent()
val authFlow = AuthFlow.fromConfig(flowConfig)

route("{sessionId}") {
registerAuthenticationMethods(methods, contextFunction)
}

post("start") {
val session = SessionManager.openExplicitGlobalSession(authFlow)
context.respond(session.toInformation())
}
}
}

fun Route.globalImplicitVc() {
route("global-implicit-vc") {
@Language("JSON")
val flowConfig = """
{
"method": "vc",
"config": {
"verification": {
"request_credentials": [
"OpenBadgeCredential"
]
}
},
"ok": true
}
""".trimIndent()
val authFlow = AuthFlow.fromConfig(flowConfig)


val contextFunction: PipelineContext<Unit, ApplicationCall>.() -> AuthContext = {
AuthContext(
tenant = call.request.host(),
sessionId = call.parameters["sessionId"],
implicitSessionGeneration = true,
initialFlow = authFlow
)
}

registerAuthenticationMethod(VerifiableCredential, contextFunction)
}
}


fun Route.globalMultistepExample() {
route("global-multistep-example") {
@Language("JSON")
Expand All @@ -304,57 +181,8 @@ fun Route.globalMultistepExample() {
}
}

/*fun Route.accountImplicitMultiStep() {
route("flow-account1") {
*//*@Language("JSON")
val flowConfig = """
{
"method": "userpass",
"ok": true
}
""".trimIndent()
val authFlow = AuthFlow.fromConfig(flowConfig)
val contextFunction: PipelineContext<Unit, ApplicationCall>.() -> AuthContext = {
AuthContext(
tenant = call.request.host(),
sessionId = call.parameters["sessionId"],
implicitSessionGeneration = true,
initialFlow = authFlow
)
}*//*
registerAuthenticationMethod(UserPass, contextFunction)
route("{sessionId}") {
registerAuthenticationMethod(TOTP, contextFunction)
}
post("start") {
val session = SessionManager.openExplicitGlobalSession(authFlow)
context.respond(session.toInformation())
}
}
}*/



fun Route.authFlowRoutes() {
// Global flows (service specifies flow)
globalImplicitSingleStep()
globalImplicitMultiStep()
globalExplicitMultiStep()

globalImplicitVc()


globalMultistepExample()

// Account flows (account specifies flow)
//accountImplicitMultiStep()
}

fun Application.testApp() {
Expand Down

0 comments on commit 5f73732

Please sign in to comment.