Usage of JWK in a JWS - json

I'm trying to learn about JWT. I've read several blog post and a github repo and I think I've understood it quite well.
There's this library in Haskell that deals with JWT and its kind. In this library, using JWK is mandatory, while most of the library I used in another language doesn't. I'm puzzled of what JWK is, seems it is hardly mentioned in the blog post I've read so far.
A quick search yields a result that what I think about JWK is, I don't know if it's right, is basically a JSON object that can be used as a secret
and specifying what algorithm is supported. Can someone clarify that this is true or no. More explanation about it will be gratefully accepted!

Related

Parsing HTML with OCaml

I'm looking for a library to parse HTML files in OCaml.
Basically the equivalent of Jsoup/Beautiful Soup.
The main requirement is being able to query the DOM with CSS selectors.
Something in the form of
page.fetch("http://www.url.com")
page.find("#tag")
I had a need for something like this recently, so after seeing this question and reading the recommendations in the comments, I wrote a library "Lambda Soup" over the weekend for fun.
You will want to use a library like ocurl or Cohttp to retrieve the actual HTML. After you have it, you can do
html |> parse $ "#tag"
to do what is asked in the question. For other possibilities and the full signature, see the documentation. You may want to look at the documentation postprocessor or tests for a fairly thorough demonstration of usage and capabilities, including CSS support and extensions.
Per comments, Lambda Soup uses Ocamlnet's HTML parser. Lambda Soup uses Markup.ml. Otherwise, it has no dependencies, except OUnit if you wish to run the tests. I'm happy for any feedback, including about modifying the interface (it is at an early stage) or discussions of adding an HTTP downloader to the library (which seems iffy because it greatly alters the scope of the library as it now is, but I am happy to hear arguments).
The license is BSD.

What alternatives are there for creating a REST-full web service API based on JSON?

We're creating a web service and we'd like 2 things:
- to be JSON based
- to be REST-full - how much so, we haven't decided
We've already implemented custom APIs but now we'd like to follow some standards, since at some point it gets a little crazy to remember all the rules, all the exceptions, and all the undocumented parts that the creator also forgot.
Are any of you using some standards that you've found useful? Or At least, what are some alternatives?
So far I know of jsonapi and HAL.
These don't seem to be good enough though, since what we'd optimaly like is to be able to:
+ define, expose and update entities and relations between them
+ define, expose and invoke operations
+ small numbers of requests are preferable, at least where it "makes sense" (i'll leave that as a blank check)
[EDIT]
Apparently, there's OData too: http://www.odata.org/
Are any of you using some standards that you've found useful? Or At least, what are some alternatives?
Between your own question and the comments most of the big names have been mentioned. I just like to also add JSON Hyper Schema:
"JSON Schema is a JSON based format for defining the structure of JSON data. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema."
http://json-schema.org/latest/json-schema-hypermedia.html
It's an extension to JSON schema and fulfils a very similar role to the others mentioned above.
I've been using json-hal for a while and like it a lot, but I'm increasingly drawn to the JSON Schema family of schemas which also handle data model definition and validation. These schemas are also the basis of the excellent Swagger REST API standard:
http://swagger.io/specification/
Hope this helps.

CakePHP - Using JSON as a datasource

I'm new here so apologies in advance if I break any rules. I'm trying to use a json datasource in cakephp. I've had little progress since viewing the twitter example in the cake documentation. I can get the /model/ listing to work, but associations do not populate and I'm generally flying blind. I was wondering if anyone had any good resources they could direct me to, as the online references that I can find seem few and far between.
Thanks.
Update: My reference material was: http://book.cakephp.org/2.0/en/models/datasources.html
Embarrassing but it's just occurred to me that this code cares little about associations. It solves the problem of "How do I present data from twitter as a model in a cakephp application?" without concerning itself with assocations between other related models. Not quite the "automagic" it presented itself as, but having taken a deeper look it's safe to say that there shouldn't be any to begin with.
If I figure it out I'll post code here. I'm going to piggy-back off the dbosource file and how it's read function handles associations.

How to use DataProtectionProvider?

I'm new to WinRT and was exploring it's security features and I've got a couple of questions regarding to Windows.Security.Cryptography.DataProtection.DataProtectionProvider class:
What encryption algorithm does it use (e.g. AES or TwoFish)?
According to MSDN document you can use symmetric key for encryption, anyone knows what do you pass in as 'protectionDescription' constructor argument if you want to do this?
Finally, the MSDN document says you have to use the parameter-less constructor before calling the UnprotectAsync method. How come you don't need to pass in a key to decrypt the data?
Thanks.
No one here explained or gave the answer to the original question. I couldn't find much information on DataProtectionProvider.
After I downloaded and went through the Metro samples as suggested by Ritch, I found out that I should be using classes under Windows.Security.Cryptography.Core namespace for data encryption.

What is the most mature JSON library for Erlang?

I wanted to use YAML but there is not a single mature YAML library for Erlang. I know there are a few JSON libraries, but was wondering which is the most mature?
Have a look at the one from mochiweb: mochijson.erl
1> mochijson:decode("{\"Name\":\"Tom\",\"Age\":10}").
{struct,[{"Name","Tom"},{"Age",10}]}
I prefer Jiffy. It works with binary and is realy fast.
1> jiffy:decode(<<"{\"Name\":\"Tom\",\"Age\":10}">>).
{[{<<"Name">>,<<"Tom">>},{<<"Age">>,10}]}
Can encode as well:
2> jiffy:encode({[{<<"Name">>,<<"Tom">>},{<<"Age">>,10}]}).
<<"{\"Name\":\"Tom\",\"Age\":10}">>
Also check out jsx. "An erlang application for consuming, producing and manipulating json. Inspired by Yajl." I haven't tried it myself yet, but it looks promising.
As a side note; I found this library through Jesse, a json schema validator by Klarna.
I use the json library provided by yaws.
Edit: I actually switched over to Jiffy, see Konstantin's answer.
Trapexit offers a really cool search feature for Erlang projects.
Lookup for JSON there, you'll find almost 13 results. Check the dates of the latest revisions, the user rating, the project activity status.
UPDATE: I've just found a similar question n StackOverflow. Apparently, they are quite happy with the erlang-json-eep-parser parser.
My favourite is mochijson2. The API is straightforward, it's fast enough for me (I never actually bothered to benchmark it though, to be honest--I'm mostly en- and de-coding small packets), and I've been using it in a stable "production server" for a year now or so. Just remember to install mochinum as well, mochijson2 uses it to encode large numbers, if you miss it, and you'll try to encode a large number, it will throw an exception.
See also: mochijson2 examples (stackoverflow)