Skip to content

Commit b0416af

Browse files
committed
finalize anti csrf partial server endpoints
1 parent 9824865 commit b0416af

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

tapir/src/main/scala/com/softwaremill/session/CsrfEndpoints.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait CsrfEndpoints {
2626
(SECURITY_INPUT, Option[String], Method, Option[String]),
2727
PRINCIPAL,
2828
Unit,
29-
_,
29+
Unit,
3030
(SECURITY_OUTPUT, Option[CookieValueWithMeta]),
3131
Unit,
3232
Any,
@@ -36,15 +36,22 @@ trait CsrfEndpoints {
3636
body
3737
}
3838

39-
def hmacTokenCsrfProtectionWithFormOrMultipart[T, SECURITY_INPUT, PRINCIPAL, SECURITY_OUTPUT, F](
39+
def hmacTokenCsrfProtectionWithFormOrMultipart[
40+
T,
41+
SECURITY_INPUT,
42+
PRINCIPAL,
43+
ERROR_OUTPUT,
44+
SECURITY_OUTPUT,
45+
F
46+
](
4047
checkMode: TapirCsrfCheckMode[T],
4148
form: Either[EndpointIO.Body[String, F], EndpointIO.Body[Seq[RawPart], F]]
4249
)(
4350
body: => PartialServerEndpointWithSecurityOutput[
4451
SECURITY_INPUT,
4552
PRINCIPAL,
4653
Unit,
47-
Unit,
54+
ERROR_OUTPUT,
4855
SECURITY_OUTPUT,
4956
Unit,
5057
Any,

tapir/src/main/scala/com/softwaremill/session/TapirCsrf.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private[session] trait TapirCsrf[T] { _: CsrfCheck =>
130130
(SECURITY_INPUT, Option[String], Method, Option[String]),
131131
PRINCIPAL,
132132
Unit,
133-
_,
133+
Unit,
134134
(SECURITY_OUTPUT, Option[CookieValueWithMeta]),
135135
Unit,
136136
Any,
@@ -161,8 +161,8 @@ private[session] trait TapirCsrf[T] { _: CsrfCheck =>
161161
}
162162
partial.endpoint
163163
.prependSecurityIn(body.securityInput)
164-
.out(body.securityOutput)
165-
.out(partial.securityOutput)
164+
//FIXME .errorOut(body.errorOutput)
165+
.out(body.securityOutput.and(partial.securityOutput))
166166
.serverSecurityLogicWithOutput {
167167
case (
168168
securityInput,
@@ -195,14 +195,15 @@ private[session] trait TapirCsrf[T] { _: CsrfCheck =>
195195
def hmacTokenCsrfProtectionWithFormOrMultipart[
196196
SECURITY_INPUT,
197197
PRINCIPAL,
198+
ERROR_OUTPUT,
198199
SECURITY_OUTPUT,
199200
F
200201
](form: Either[EndpointIO.Body[String, F], EndpointIO.Body[Seq[RawPart], F]])(
201202
body: => PartialServerEndpointWithSecurityOutput[
202203
SECURITY_INPUT,
203204
PRINCIPAL,
204205
Unit,
205-
Unit,
206+
ERROR_OUTPUT,
206207
SECURITY_OUTPUT,
207208
Unit,
208209
Any,
@@ -251,8 +252,7 @@ private[session] trait TapirCsrf[T] { _: CsrfCheck =>
251252
}
252253
partial.endpoint
253254
.prependSecurityIn(body.securityInput)
254-
.out(body.securityOutput)
255-
.out(partial.securityOutput)
255+
.out(body.securityOutput.and(partial.securityOutput))
256256
.serverSecurityLogicWithOutput {
257257
case (
258258
securityInput,

tapir/src/main/scala/com/softwaremill/session/TapirEndpoints.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait TapirEndpoints extends SessionEndpoints with CsrfEndpoints {
1717
(Seq[Option[String]], Option[String], Method, Option[String]),
1818
T,
1919
Unit,
20-
_,
20+
Unit,
2121
(Seq[Option[String]], Option[CookieValueWithMeta]),
2222
Unit,
2323
Any,
@@ -35,7 +35,7 @@ trait TapirEndpoints extends SessionEndpoints with CsrfEndpoints {
3535
(Seq[Option[String]], Option[String], Method, Option[String]),
3636
Option[T],
3737
Unit,
38-
_,
38+
Unit,
3939
(Seq[Option[String]], Option[CookieValueWithMeta]),
4040
Unit,
4141
Any,

0 commit comments

Comments
 (0)