-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement security fields from openapi to malli route data. #14
base: main
Are you sure you want to change the base?
Conversation
…e-vector] pairs.
thanks! will have a look asap! |
Implement security as a malli route data, this can then be read by interceptor / midleware. Given a doc like:
Produce routes like:
|
Need to add a test, only tested at the repl with no security info, with 1 and with many. |
@@ -5,6 +5,7 @@ | |||
; https://opensource.org/licenses/MIT. | |||
|
|||
{:deps {io.swagger.parser.v3/swagger-parser {:mvn/version "2.1.25"}} | |||
:paths ["resources" "src"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this and put the test
dir? in something like a specs
dir maybe. we can just use (slurp "specs/security-users.yml")
. I'd rather not have things that aren't part of the final artifact in resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it makes sense I just added this to have a repl going.
(->> security-reqs | ||
(mapcat seq) | ||
(map (juxt key val)) | ||
(into []))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this into
can be dropped for a mapv
before this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking more, is this conversion even needed or does is just work in reitit as its all Maps and Lists anyways?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just creating route data. It won't work in reitit until you add middleware that uses that data.
Although it's opinionated, I chose to represent it as a vector of vectors because it convey the logical OR of having multiple security schemes.
This could have been a map but I think of map a as AND.
And yes, this can also be done with a mapv, feel free to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Let's add some docs about it on the README.
"listUsersSingle" (constantly :ok) | ||
"listUsersNoScope" (constantly :ok) | ||
"listUsersNoSecurity" (constantly :ok)} | ||
api-spec (slurp (io/resource "security-users.yml")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use a slurp without the resource like mentioned before
Rest looks pretty good! thanks! |
@JohanCodinha can I get some reitit middleware/interceptor examples for the readme thst uses this? I'm happy to merge this after that. 😄 |
No description provided.