Giter VIP home page Giter VIP logo

java-json-canonicalization's People

Contributors

erdtman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

java-json-canonicalization's Issues

Issue with canonicalisation of JSON object with certain JSON array member

Hey,

I'd like to report an issue that we managed to finally pin down today.

I'm pasting the concrete JSON that was causing different outputs of the JsonCanonicalizer for a given string:

String jsonIn = "{\"sub\":\"alice\",\"cid\":\"1\",\"scp\":[\"openid\",\"email\"],\"irt\":false,\"rtl\":-1,\"atl\":300,\"ate\":\"S\",\"atc\":false,\"iat\":1613669294,\"clm\":[\"email_verified\",\"email\"],\"rts\":\"_bM0U_knzP20VzbVAuzmvA\",\"k\":\"[\\\"alice\\\",\\\"\\\",\\\"1\\\"]\",\"tid\":\"t2\"}";
		
System.out.println(new JsonCanonicalizer(jsonIn).getEncodedString());
		
String jsonOut = "{\"sub\":\"alice\",\"scp\":[\"openid\",\"email\"],\"clm\":[\"email\",\"email_verified\"],\"irt\":false,\"rtl\":-1,\"k\":\"[\\\"alice\\\",\\\"\\\",\\\"1\\\"]\",\"tid\":\"t2\",\"rts\":\"_bM0U_knzP20VzbVAuzmvA\",\"atc\":false,\"ate\":\"S\",\"atl\":300,\"iat\":1613669294,\"cid\":\"1\"}";
		
System.out.println(new JsonCanonicalizer(jsonOut).getEncodedString());

The first printout produces:

{"atc":false,"ate":"S","atl":300,"cid":"1","clm":["email_verified","email"],"iat":1613669294,"irt":false,"k":"[\"alice\",\"\",\"1\"]","rtl":-1,"rts":"_bM0U_knzP20VzbVAuzmvA","scp":["openid","email"],"sub":"alice","tid":"t2"}

The second:

{"atc":false,"ate":"S","atl":300,"cid":"1","clm":["email","email_verified"],"iat":1613669294,"irt":false,"k":"[\"alice\",\"\",\"1\"]","rtl":-1,"rts":"_bM0U_knzP20VzbVAuzmvA","scp":["openid","email"],"sub":"alice","tid":"t2"}

The difference is in the ordering of the items in the "clm" JSON array - "email" and "email_verified".

The library was used to append HMACs to items stored in DynamoDB, which returns the JSON in non-deterministic order, hence the need for canonicalisation.

Version is 1.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.