Fork me on GitHub
#yada
<
2016-07-14
>
dominicm05:07:19

There is some jwt example in the yada project, somewhere.

mccraigmccraig08:07:25

@severed-infinity: i'm using buddy's JWT - dyu have some questions ?

severed-infinity10:07:40

@dominicm: thank you for that link it is along the lines of what I was looking for. @mccraigmccraig: yes I am trying to first off test it through swagger, is it possible with yada? secondly I’ve currently 2 functions in my system that produces yada/resource models register and login with register sending a string value over the line with a user then add it to the system and return a JWT, where as with login I am trying to use the access-control of the resource model as means of authorisation and validation

mccraigmccraig10:07:43

@severed-infinity: yes - you will need to modify your swagger-ui source a little... take a look at the index.html and compare with this https://www.refheap.com/04cd14052282d2404711ca95b

mccraigmccraig10:07:17

then the "api-key" of the swagger-ui form will be supplied as the JWT Authorization header

mccraigmccraig10:07:55

i haven't used the access-control of the resource models yet... i have a custom yada interceptor for authenticated resources

severed-infinity10:07:44

is there any particular file in the project I must modify or the opened webpage each itme?

mccraigmccraig10:07:52

@severed-infinity: dyu mean in the swagger-ui project ?

severed-infinity10:07:44

I assumed in yada it produces a swagger-ui through possibly the swagger namespace coming on some file, or am I missing something about swagger

mccraigmccraig10:07:36

yada produces the swagger.json describing the API... swagger-ui is a separate project which parses a swagger.json and lets you interact with the API

severed-infinity10:07:52

ah I did not know that

mccraigmccraig10:07:50

i bundle the swagger-ui under resources in my api project, and serve it with a bidi route like ["swagger-ui/" (bidi/->ResourcesMaybe {:prefix "swagger-ui/"})]

mccraigmccraig10:07:55

that way i can modify swagger-ui to use JWT authentication (it's an easy mod - it's designed to be modified to support different auth schemes) and always default to the correct api location

severed-infinity11:07:46

Ah I get you now, just one last thing in regards to yada will it automatically use this customised swagger-ui from the resource folder when using (yada/swaggered) function?

mccraigmccraig11:07:11

no, it's up to you to serve the swagger-ui ... if you are using bidi for routing and have a vanilla project.clj then the route above will serve it from the resources/swagger-ui path

ikitommi14:07:17

for the lazy, there is also the ring-swagger-ui (`[metosin/ring-swagger-ui "2.1.4-0”]`), has few helpers over the vanilla swagger-ui: one can customize some parts of ui from the backend code with clojure. For example, one can set how the “Authorize” input send info to the backend.

ikitommi14:07:06

e.g. the :securityDefinitions of the swagger spec affect the ui. There is an open issue of that in the swagger-ui, labelled won’t be fixed.. :securityDefinitions {:api_key {:type "apiKey", :name "x-api-key", :in "header”}

ikitommi14:07:36

to get those working, one needs to use the ring.swagger.ui/swagger-ui ring-route function.

lmergen16:07:01

hmmm, i'm trying to get swagger to work, but i think i have made some configuration error somewhere

lmergen16:07:10

(sorry, i'm joining the queue of people with swagger problems :))

lmergen16:07:51

the swagger.json loads perfectly fine, but i think there's a configuration issue with the ui somewhere, and after about two hours of debugging, i don't know where to look anymore

lmergen16:07:46

long story short: for the endpoints where swagger-ui should be listening at, i'm getting internal server errors that last-modified is not a valid date: http://qs.lc/hpuka

lmergen16:07:17

this feels incredibly weird to me, and feels like a configuration issue

lmergen16:07:38

so, that's the code that links all my routes together

lmergen16:07:54

and i see that error message when i go to /swagger , for example

lmergen16:07:12

the code is pretty much the same as the edge project, except that i'm using lein