{"action":"created","comment":{"url":"https://api.github.com/repos/lawliet89/biscuit/pulls/comments/204967190","pull_request_review_id":140128047,"id":204967190,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDk2NzE5MA==","diff_hunk":"@@ -851,103 +854,272 @@ pub struct RegisteredClaims {\n }\n \n #[derive(Debug, Eq, PartialEq, Clone, Copy, Default)]\n-/// Options for claims time validation\n+/// Options for claims presence validation\n+///\n+/// By default, no claims (namely `iat`, `exp`, `nbf`, `iss`, `aud`)\n+/// are required, and they pass validation if they are missing.\n+///\n+pub struct ClaimPresenceOptions {\n+    /// Whether the `iat` or `Issued At` field is required\n+    pub issued_at: Presence,\n+    /// Whether the `nbf` or `Not Before` field is required\n+    pub not_before: Presence,\n+    /// Whether the `exp` or `Expiry` field is required\n+    pub expiry: Presence,\n+    /// Whether the `iss` or `Issuer` field is required\n+    pub issuer: Presence,\n+    /// Whether the `aud` or `Audience` field is required\n+    pub audience: Presence,\n+    /// Whether the `sub` or `Subject` field is required\n+    pub subject: Presence,\n+    /// Whether the `jti` or `JWT ID` field is required\n+    pub id: Presence,\n+}\n+\n+impl ClaimPresenceOptions {\n+    /// Returns a ClaimPresenceOptions where every claim is required as per [RFC7523](https://tools.ietf.org/html/rfc7523#section-3)\n+    pub fn strict() -> Self {\n+        use Presence::*;\n+        ClaimPresenceOptions {\n+            issued_at: Required,\n+            not_before: Required,\n+            expiry: Required,\n+            issuer: Required,\n+            audience: Required,\n+            subject: Required,\n+            id: Required,\n+        }\n+    }\n+}\n+\n+#[derive(Debug, Eq, PartialEq, Clone, Copy)]\n+/// Options for validating temporal claims\n ///\n-/// By default, no temporal claims (namely `iat`, `exp`, `nbf`)\n-/// are required, and they will pass validation if they are missing.\n+///\n+/// Should any temporal claims be needed, set the appropriate fields.\n+///\n+/// To deal with clock drifts, you might want to provide an `epsilon` error margin in the form of a\n+/// `chrono::Duration` to allow time comparisons to fall within the margin.\n+pub struct TemporalOptions {\n+    /// Allow for some leeway for clock drifts, limited to this duration during temporal validation\n+    pub epsilon: Duration,\n+\n+    /// Specify a time to use in temporal validation instead of `Now`\n+    pub now: Option<DateTime<Utc>>,\n+}\n+\n+impl Default for TemporalOptions {\n+    fn default() -> Self {\n+        TemporalOptions {\n+            epsilon: Duration::seconds(0),\n+            now: None,\n+        }\n+    }\n+}\n+\n+#[derive(Eq, PartialEq, Clone)]\n+/// Options for claims validation\n+///\n+/// If a claim is missing, it passes validation unless the claim is marked as required within the\n+/// `claim_presence_options`.\n+///\n+/// By default only expiry-related claims are validated (namely `exp`, `nbf`, `iat`).\n+///\n+///\n+/// are required, and they pass validation if they are missing.\n ///\n /// Should any temporal claims be needed, set the appropriate fields.\n ///\n /// To deal with clock drifts, you might want to provide an `epsilon` error margin in the form of a\n /// `std::time::Duration` to allow time comparisons to fall within the margin.\n-pub struct TemporalValidationOptions {\n+pub struct ValidationOptions {\n+    ///Claims marked as required will trigger a validation failure if they are missing\n+    pub claim_presence_options: ClaimPresenceOptions,\n+\n+    ///Define how to validate temporal claims\n+    pub temporal_options: TemporalOptions,\n+\n     /// Whether the `iat` or `Issued At` field is required\n-    pub issued_at_required: bool,\n+    /// Parameter shows the maximum age of a token to be accepted.\n+    pub issued_at: Validation<Duration>,\n     /// Whether the `nbf` or `Not Before` field is required\n-    pub not_before_required: bool,\n+    pub not_before: Validation<()>,\n     /// Whether the `exp` or `Expiry` field is required","path":"src/lib.rs","position":118,"original_position":118,"commit_id":"afa48f7dbb14164af3969a537bba3e279dcef582","original_commit_id":"afa48f7dbb14164af3969a537bba3e279dcef582","user":{"login":"lawliet89","id":983101,"node_id":"MDQ6VXNlcjk4MzEwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/983101?v=4","gravatar_id":"","url":"https://api.github.com/users/lawliet89","html_url":"https://github.com/lawliet89","followers_url":"https://api.github.com/users/lawliet89/followers","following_url":"https://api.github.com/users/lawliet89/following{/other_user}","gists_url":"https://api.github.com/users/lawliet89/gists{/gist_id}","starred_url":"https://api.github.com/users/lawliet89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawliet89/subscriptions","organizations_url":"https://api.github.com/users/lawliet89/orgs","repos_url":"https://api.github.com/users/lawliet89/repos","events_url":"https://api.github.com/users/lawliet89/events{/privacy}","received_events_url":"https://api.github.com/users/lawliet89/received_events","type":"User","site_admin":false},"body":"This should now read something like \r\n\r\n    Validation options for `exp` or `Expiry` field if present","created_at":"2018-07-25T02:41:44Z","updated_at":"2018-07-25T02:48:44Z","html_url":"https://github.com/lawliet89/biscuit/pull/99#discussion_r204967190","pull_request_url":"https://api.github.com/repos/lawliet89/biscuit/pulls/99","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/comments/204967190"},"html":{"href":"https://github.com/lawliet89/biscuit/pull/99#discussion_r204967190"},"pull_request":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/99"}}},"pull_request":{"url":"https://api.github.com/repos/lawliet89/biscuit/pulls/99","id":203058228,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDU4MjI4","html_url":"https://github.com/lawliet89/biscuit/pull/99","diff_url":"https://github.com/lawliet89/biscuit/pull/99.diff","patch_url":"https://github.com/lawliet89/biscuit/pull/99.patch","issue_url":"https://api.github.com/repos/lawliet89/biscuit/issues/99","number":99,"state":"open","locked":false,"title":"Add iss, aud validations, and extend validationError","user":{"login":"axos88","id":1281218,"node_id":"MDQ6VXNlcjEyODEyMTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1281218?v=4","gravatar_id":"","url":"https://api.github.com/users/axos88","html_url":"https://github.com/axos88","followers_url":"https://api.github.com/users/axos88/followers","following_url":"https://api.github.com/users/axos88/following{/other_user}","gists_url":"https://api.github.com/users/axos88/gists{/gist_id}","starred_url":"https://api.github.com/users/axos88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axos88/subscriptions","organizations_url":"https://api.github.com/users/axos88/orgs","repos_url":"https://api.github.com/users/axos88/repos","events_url":"https://api.github.com/users/axos88/events{/privacy}","received_events_url":"https://api.github.com/users/axos88/received_events","type":"User","site_admin":false},"body":"This PR drops the String result from the validation errors, and replaces them with more fine-grained types / enum varians.\r\n\r\nIt also refactors the validation of the token and adds iss and aud validations, and makes it possible to require the presence of other RFC-mandated fields.","created_at":"2018-07-22T13:54:20Z","updated_at":"2018-07-25T02:48:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63e1f415c5c10bef27149e84eb6d03ad629f5fe8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lawliet89/biscuit/pulls/99/commits","review_comments_url":"https://api.github.com/repos/lawliet89/biscuit/pulls/99/comments","review_comment_url":"https://api.github.com/repos/lawliet89/biscuit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lawliet89/biscuit/issues/99/comments","statuses_url":"https://api.github.com/repos/lawliet89/biscuit/statuses/afa48f7dbb14164af3969a537bba3e279dcef582","head":{"label":"axos88:validations","ref":"validations","sha":"afa48f7dbb14164af3969a537bba3e279dcef582","user":{"login":"axos88","id":1281218,"node_id":"MDQ6VXNlcjEyODEyMTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1281218?v=4","gravatar_id":"","url":"https://api.github.com/users/axos88","html_url":"https://github.com/axos88","followers_url":"https://api.github.com/users/axos88/followers","following_url":"https://api.github.com/users/axos88/following{/other_user}","gists_url":"https://api.github.com/users/axos88/gists{/gist_id}","starred_url":"https://api.github.com/users/axos88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axos88/subscriptions","organizations_url":"https://api.github.com/users/axos88/orgs","repos_url":"https://api.github.com/users/axos88/repos","events_url":"https://api.github.com/users/axos88/events{/privacy}","received_events_url":"https://api.github.com/users/axos88/received_events","type":"User","site_admin":false},"repo":{"id":138126793,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgxMjY3OTM=","name":"biscuit","full_name":"axos88/biscuit","owner":{"login":"axos88","id":1281218,"node_id":"MDQ6VXNlcjEyODEyMTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1281218?v=4","gravatar_id":"","url":"https://api.github.com/users/axos88","html_url":"https://github.com/axos88","followers_url":"https://api.github.com/users/axos88/followers","following_url":"https://api.github.com/users/axos88/following{/other_user}","gists_url":"https://api.github.com/users/axos88/gists{/gist_id}","starred_url":"https://api.github.com/users/axos88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axos88/subscriptions","organizations_url":"https://api.github.com/users/axos88/orgs","repos_url":"https://api.github.com/users/axos88/repos","events_url":"https://api.github.com/users/axos88/events{/privacy}","received_events_url":"https://api.github.com/users/axos88/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/axos88/biscuit","description":"JOSE (JSON Web Token) Library for Rust","fork":true,"url":"https://api.github.com/repos/axos88/biscuit","forks_url":"https://api.github.com/repos/axos88/biscuit/forks","keys_url":"https://api.github.com/repos/axos88/biscuit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/axos88/biscuit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/axos88/biscuit/teams","hooks_url":"https://api.github.com/repos/axos88/biscuit/hooks","issue_events_url":"https://api.github.com/repos/axos88/biscuit/issues/events{/number}","events_url":"https://api.github.com/repos/axos88/biscuit/events","assignees_url":"https://api.github.com/repos/axos88/biscuit/assignees{/user}","branches_url":"https://api.github.com/repos/axos88/biscuit/branches{/branch}","tags_url":"https://api.github.com/repos/axos88/biscuit/tags","blobs_url":"https://api.github.com/repos/axos88/biscuit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/axos88/biscuit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/axos88/biscuit/git/refs{/sha}","trees_url":"https://api.github.com/repos/axos88/biscuit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/axos88/biscuit/statuses/{sha}","languages_url":"https://api.github.com/repos/axos88/biscuit/languages","stargazers_url":"https://api.github.com/repos/axos88/biscuit/stargazers","contributors_url":"https://api.github.com/repos/axos88/biscuit/contributors","subscribers_url":"https://api.github.com/repos/axos88/biscuit/subscribers","subscription_url":"https://api.github.com/repos/axos88/biscuit/subscription","commits_url":"https://api.github.com/repos/axos88/biscuit/commits{/sha}","git_commits_url":"https://api.github.com/repos/axos88/biscuit/git/commits{/sha}","comments_url":"https://api.github.com/repos/axos88/biscuit/comments{/number}","issue_comment_url":"https://api.github.com/repos/axos88/biscuit/issues/comments{/number}","contents_url":"https://api.github.com/repos/axos88/biscuit/contents/{+path}","compare_url":"https://api.github.com/repos/axos88/biscuit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/axos88/biscuit/merges","archive_url":"https://api.github.com/repos/axos88/biscuit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/axos88/biscuit/downloads","issues_url":"https://api.github.com/repos/axos88/biscuit/issues{/number}","pulls_url":"https://api.github.com/repos/axos88/biscuit/pulls{/number}","milestones_url":"https://api.github.com/repos/axos88/biscuit/milestones{/number}","notifications_url":"https://api.github.com/repos/axos88/biscuit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/axos88/biscuit/labels{/name}","releases_url":"https://api.github.com/repos/axos88/biscuit/releases{/id}","deployments_url":"https://api.github.com/repos/axos88/biscuit/deployments","created_at":"2018-06-21T06:10:01Z","updated_at":"2018-07-23T17:52:43Z","pushed_at":"2018-07-25T01:07:59Z","git_url":"git://github.com/axos88/biscuit.git","ssh_url":"git@github.com:axos88/biscuit.git","clone_url":"https://github.com/axos88/biscuit.git","svn_url":"https://github.com/axos88/biscuit","homepage":"https://lawliet89.github.io/biscuit","size":1149,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lawliet89:master","ref":"master","sha":"b55df81c3f0ef7faad9ac6549226b02ca192425c","user":{"login":"lawliet89","id":983101,"node_id":"MDQ6VXNlcjk4MzEwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/983101?v=4","gravatar_id":"","url":"https://api.github.com/users/lawliet89","html_url":"https://github.com/lawliet89","followers_url":"https://api.github.com/users/lawliet89/followers","following_url":"https://api.github.com/users/lawliet89/following{/other_user}","gists_url":"https://api.github.com/users/lawliet89/gists{/gist_id}","starred_url":"https://api.github.com/users/lawliet89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawliet89/subscriptions","organizations_url":"https://api.github.com/users/lawliet89/orgs","repos_url":"https://api.github.com/users/lawliet89/repos","events_url":"https://api.github.com/users/lawliet89/events{/privacy}","received_events_url":"https://api.github.com/users/lawliet89/received_events","type":"User","site_admin":false},"repo":{"id":83498002,"node_id":"MDEwOlJlcG9zaXRvcnk4MzQ5ODAwMg==","name":"biscuit","full_name":"lawliet89/biscuit","owner":{"login":"lawliet89","id":983101,"node_id":"MDQ6VXNlcjk4MzEwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/983101?v=4","gravatar_id":"","url":"https://api.github.com/users/lawliet89","html_url":"https://github.com/lawliet89","followers_url":"https://api.github.com/users/lawliet89/followers","following_url":"https://api.github.com/users/lawliet89/following{/other_user}","gists_url":"https://api.github.com/users/lawliet89/gists{/gist_id}","starred_url":"https://api.github.com/users/lawliet89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawliet89/subscriptions","organizations_url":"https://api.github.com/users/lawliet89/orgs","repos_url":"https://api.github.com/users/lawliet89/repos","events_url":"https://api.github.com/users/lawliet89/events{/privacy}","received_events_url":"https://api.github.com/users/lawliet89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lawliet89/biscuit","description":"JOSE (JSON Web Token) Library for Rust","fork":false,"url":"https://api.github.com/repos/lawliet89/biscuit","forks_url":"https://api.github.com/repos/lawliet89/biscuit/forks","keys_url":"https://api.github.com/repos/lawliet89/biscuit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lawliet89/biscuit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lawliet89/biscuit/teams","hooks_url":"https://api.github.com/repos/lawliet89/biscuit/hooks","issue_events_url":"https://api.github.com/repos/lawliet89/biscuit/issues/events{/number}","events_url":"https://api.github.com/repos/lawliet89/biscuit/events","assignees_url":"https://api.github.com/repos/lawliet89/biscuit/assignees{/user}","branches_url":"https://api.github.com/repos/lawliet89/biscuit/branches{/branch}","tags_url":"https://api.github.com/repos/lawliet89/biscuit/tags","blobs_url":"https://api.github.com/repos/lawliet89/biscuit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lawliet89/biscuit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lawliet89/biscuit/git/refs{/sha}","trees_url":"https://api.github.com/repos/lawliet89/biscuit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lawliet89/biscuit/statuses/{sha}","languages_url":"https://api.github.com/repos/lawliet89/biscuit/languages","stargazers_url":"https://api.github.com/repos/lawliet89/biscuit/stargazers","contributors_url":"https://api.github.com/repos/lawliet89/biscuit/contributors","subscribers_url":"https://api.github.com/repos/lawliet89/biscuit/subscribers","subscription_url":"https://api.github.com/repos/lawliet89/biscuit/subscription","commits_url":"https://api.github.com/repos/lawliet89/biscuit/commits{/sha}","git_commits_url":"https://api.github.com/repos/lawliet89/biscuit/git/commits{/sha}","comments_url":"https://api.github.com/repos/lawliet89/biscuit/comments{/number}","issue_comment_url":"https://api.github.com/repos/lawliet89/biscuit/issues/comments{/number}","contents_url":"https://api.github.com/repos/lawliet89/biscuit/contents/{+path}","compare_url":"https://api.github.com/repos/lawliet89/biscuit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lawliet89/biscuit/merges","archive_url":"https://api.github.com/repos/lawliet89/biscuit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lawliet89/biscuit/downloads","issues_url":"https://api.github.com/repos/lawliet89/biscuit/issues{/number}","pulls_url":"https://api.github.com/repos/lawliet89/biscuit/pulls{/number}","milestones_url":"https://api.github.com/repos/lawliet89/biscuit/milestones{/number}","notifications_url":"https://api.github.com/repos/lawliet89/biscuit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lawliet89/biscuit/labels{/name}","releases_url":"https://api.github.com/repos/lawliet89/biscuit/releases{/id}","deployments_url":"https://api.github.com/repos/lawliet89/biscuit/deployments","created_at":"2017-03-01T01:37:32Z","updated_at":"2018-07-25T00:57:14Z","pushed_at":"2018-07-25T01:08:00Z","git_url":"git://github.com/lawliet89/biscuit.git","ssh_url":"git@github.com:lawliet89/biscuit.git","clone_url":"https://github.com/lawliet89/biscuit.git","svn_url":"https://github.com/lawliet89/biscuit","homepage":"https://lawliet89.github.io/biscuit","size":1148,"stargazers_count":23,"watchers_count":23,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":20,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":10,"open_issues":20,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/99"},"html":{"href":"https://github.com/lawliet89/biscuit/pull/99"},"issue":{"href":"https://api.github.com/repos/lawliet89/biscuit/issues/99"},"comments":{"href":"https://api.github.com/repos/lawliet89/biscuit/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/99/comments"},"review_comment":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lawliet89/biscuit/pulls/99/commits"},"statuses":{"href":"https://api.github.com/repos/lawliet89/biscuit/statuses/afa48f7dbb14164af3969a537bba3e279dcef582"}},"author_association":"NONE"}}
{"actor":{"display_login":"lawliet89"}}