{"action":"created","issue":{"url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/73","repository_url":"https://api.github.com/repos/pauldijou/jwt-scala","labels_url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/73/comments","events_url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/73/events","html_url":"https://github.com/pauldijou/jwt-scala/issues/73","id":284189717,"number":73,"title":"make JwtJson4s.parseClaim, JwtJson4s.parseHeader publicly accessible","user":{"login":"evbo","id":6313004,"avatar_url":"https://avatars3.githubusercontent.com/u/6313004?v=4","gravatar_id":"","url":"https://api.github.com/users/evbo","html_url":"https://github.com/evbo","followers_url":"https://api.github.com/users/evbo/followers","following_url":"https://api.github.com/users/evbo/following{/other_user}","gists_url":"https://api.github.com/users/evbo/gists{/gist_id}","starred_url":"https://api.github.com/users/evbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evbo/subscriptions","organizations_url":"https://api.github.com/users/evbo/orgs","repos_url":"https://api.github.com/users/evbo/repos","events_url":"https://api.github.com/users/evbo/events{/privacy}","received_events_url":"https://api.github.com/users/evbo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-12-22T15:31:27Z","updated_at":"2017-12-22T18:37:12Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\n\r\nI am not able to use `JwtJson4s.decode()` without first getting the publicKey (since my signature is always non-empty). But in order to get the publicKey, my specific approach to using JWT involves looking up the publicKey from a database using the so-called [kid header claim](https://stackoverflow.com/a/43870513/1080804).\r\n\r\nSo, the process is:\r\n\r\n1) decode the claims\r\n2) check if the claims are expired (if not continue)\r\n3) decode the header\r\n4) get the `kid` from the decoded header\r\n5) select the corresponding publicKey from the database based on the `kid`\r\n6) using the publicKey, validate\r\n\r\nThis means I ended up copying and pasting the `parse` boilerplate of [these protected methods](https://github.com/pauldijou/jwt-scala/blob/989f6d4a51b32bf9edff7c5dc048dc6021027802/json/json4s-jackson/src/main/scala/JwtJson4sJackson.scala#L25-L26), that way I didn't need any `key` to decode the claims:\r\n\r\n```\r\nval parts = token.split(\"\\\\.\")\r\nval claims = JwtJson4s.readClaim(parse(JwtBase64.decodeString(parts(1))))\r\nval keyId = extractString(parse(JwtBase64.decodeString(parts(0))), \"kid\").get\r\n```\r\n\r\nWould it be alright to make those methods publicly accessible for this fairly common use case? Or, could there be a `decodeAll` method [that did not perform validate](https://github.com/pauldijou/jwt-scala/blob/8d3210baca2383ffb812b81e3d5c1b448fa231dd/core/common/src/main/scala/Jwt.scala#L401)?\r\n\r\nHere is the boilerplate used above that it would help to avoid:\r\n\r\n```\r\nprotected def parse(value: String): JObject = jparse(value) match {\r\n    case res: JObject => res\r\n    case _ => throw new RuntimeException(s\"Couldn't parse [$value] to a JObject\")\r\n  }\r\n\r\n  private def extractString(json: JObject, fieldName: String): Option[String] = (json \\ fieldName) match {\r\n    case JString(value) => Option(value)\r\n    case JNull => None\r\n    case JNothing => None\r\n    case _ => throw new JwtNonStringException(fieldName)\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/comments/353653318","html_url":"https://github.com/pauldijou/jwt-scala/issues/73#issuecomment-353653318","issue_url":"https://api.github.com/repos/pauldijou/jwt-scala/issues/73","id":353653318,"user":{"login":"evbo","id":6313004,"avatar_url":"https://avatars3.githubusercontent.com/u/6313004?v=4","gravatar_id":"","url":"https://api.github.com/users/evbo","html_url":"https://github.com/evbo","followers_url":"https://api.github.com/users/evbo/followers","following_url":"https://api.github.com/users/evbo/following{/other_user}","gists_url":"https://api.github.com/users/evbo/gists{/gist_id}","starred_url":"https://api.github.com/users/evbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evbo/subscriptions","organizations_url":"https://api.github.com/users/evbo/orgs","repos_url":"https://api.github.com/users/evbo/repos","events_url":"https://api.github.com/users/evbo/events{/privacy}","received_events_url":"https://api.github.com/users/evbo/received_events","type":"User","site_admin":false},"created_at":"2017-12-22T18:37:12Z","updated_at":"2017-12-22T18:37:12Z","author_association":"NONE","body":"I like that idea, but my understanding is that Scala does not allow you to directly extend an object. But if it were a trait then I would be able to. Does that sound right to you?\r\n\r\nhttps://stackoverflow.com/q/7625040/1080804"}}
{"actor":{"display_login":"evbo"}}