softwaremill / softwaremill/tapir
Let serverSecurityLogic access path values
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
Given this code I have some doubts
// user/{id}
val getUser = endpoint
.securityIn(sttp.tapir.auth.bearer[AuthEncodedToken]())
.in("user")
.in(path[UserId]("id"))
val ep = getUser
.serverSecurityLogic(token => decodeAndValidateToken(token))
.serverLogic(token => userId => canAccessOrForbidden(token, userId) { ... })
The problem is that with this design within serverSecurityLogic i can just decode the token, if I want to check that the token has the rights to access that user I have to move this logic in serverLogic because I don't have access to the UserId.
This force to have the security logic in two places.
It would be great to have access to the endpoint path values within serverSecurityLogic in order to have the security checks all in one place.
Am I not seeing it right ? Is there a solution ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the serverSecurityLogic API and the endpoint path handling shown in the issue. Determine whether security logic can receive decoded path values alongside the token without duplicating authorization checks, and define completion as allowing the user path value to participate in the security check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100