{"action":"created","comment":{"url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/comments/171312685","pull_request_review_id":100143084,"id":171312685,"diff_hunk":"@@ -1,70 +1,138 @@\n # frozen_string_literal: true\n \n+require 'cerner/oauth1a/oauth_error'\n+require 'cerner/oauth1a/protocol'\n+require 'uri'\n+\n module Cerner\n   module OAuth1a\n \n-    # Public: An OAuth 1.0a Access Token.\n+    # Public: A Cerner OAuth 1.0a Access Token and related request parameters for use in Consumer or\n+    # Service Provider use cases.\n     class AccessToken\n+      # Public: Constructs an AccessToken using the value of an HTTP Authorization Header based on\n+      # the OAuth HTTP Authorization Scheme (https://oauth.net/core/1.0a/#auth_header).\n+      #\n+      # value - A String containing the HTTP Authorization Header value.\n+      #\n+      # Returns an AccessToken.\n+      #\n+      # Raises a Cerner::OAuth1a::OAuthError with a populated oauth_problem if any of the parameters\n+      # in the value are invalid.\n+      def self.from_authorization_header(value)\n+        params = Protocol.parse_authorization_header(value)\n+\n+        raise OAuthError.new('', nil, 'version_rejected') if params[:oauth_version] && params[:oauth_version] != '1.0'\n+\n+        begin\n+          AccessToken.new(\n+            consumer_key: params[:oauth_consumer_key],\n+            nonce: params[:oauth_nonce],\n+            timestamp: params[:oauth_timestamp],\n+            token: params[:oauth_token],\n+            signature_method: params[:oauth_signature_method],\n+            signature: params[:oauth_signature]\n+          )\n+        rescue ArgumentError => ae\n+          raise OAuthError.new(ae.message, nil, 'parameter_absent')\n+        end\n+      end\n+\n       # Returns the String Accessor Secret related to this token.\n       attr_reader :accessor_secret\n-      # Returns the String Consumer Key related to this token.\n+      # Returns the String Consumer Key (oauth_consumer_key) related to this token.\n       attr_reader :consumer_key\n       # Returns the Time this token expires at.\n       attr_reader :expires_at\n-      # Returns the String nonce related to this token.\n+      # Returns the String nonce (oauth_nonce) related to this token.\n       attr_reader :nonce\n-      # Returns the Time this token was created.\n+      # Returns the Time this token was created (oauth_timestamp).\n       attr_reader :timestamp\n-      # Returns the String Token.\n+      # Returns the String Token (oauth_token).\n       attr_reader :token\n       # Returns the String Token Secret related to this token.\n       attr_reader :token_secret\n+      # Returns the String Signature Method (oauth_signature_method) related to this token.\n+      attr_reader :signature_method\n+      # Returns the String Signature (oauth_signature) related to this token.\n+      attr_reader :signature\n \n       # Public: Constructs an instance.\n       #\n       # arguments - The keyword arguments of the method:\n-      #             :accessor_secret - The String representing the accessor secret.\n-      #             :consumer_key    - The String representing the consumer key.\n-      #             :expires_at      - A Time representing the expiration moment or any object\n-      #                                responding to to_i that represents the expiration moment\n-      #                                as the number of seconds since the epoch.\n-      #             :nonce           - The String representing the nonce.\n-      #             :expires_at      - A Time representing the creation moment or any object\n-      #                                responding to to_i that represents the creation moment\n-      #                                as the number of seconds since the epoch.\n-      #             :token           - The String representing the token.\n-      #             :token_secret    - The String representing the token secret.\n-      #\n-      # Raises ArgumentError if any of the arguments is nil\n-      def initialize(accessor_secret:, consumer_key:, expires_at:, nonce:, timestamp:, token:, token_secret:)\n-        raise ArgumentError, 'accessor_secret is nil' unless accessor_secret\n+      #             :accessor_secret  - The optional String representing the accessor secret.\n+      #             :consumer_key     - The required String representing the consumer key.\n+      #             :expires_at       - An optional Time representing the expiration moment or any\n+      #                                 object responding to to_i that represents the expiration\n+      #                                 moment as the number of seconds since the epoch.\n+      #             :nonce            - The required String representing the nonce.\n+      #             :timestamp        - A required Time representing the creation moment or any\n+      #                                 object responding to to_i that represents the creation\n+      #                                 moment as the number of seconds since the epoch.\n+      #             :token            - The required String representing the token.\n+      #             :token_secret     - The required String representing the token secret.\n+      #             :signature_method - The optional String representing the signature method.\n+      #                                 Defaults to PLAINTEXT.\n+      #             :signature        - The optional String representing the signature.\n+      #                                 Defaults to nil.\n+      #\n+      # Raises ArgumentError if consumer_key, nonce, timestamp, token or signature_method is nil.\n+      def initialize(\n+        accessor_secret: nil,\n+        consumer_key:,\n+        expires_at: nil,\n+        nonce:,\n+        timestamp:,\n+        token:,\n+        token_secret: nil,\n+        signature_method: 'PLAINTEXT',\n+        signature: nil\n+      )\n         raise ArgumentError, 'consumer_key is nil' unless consumer_key\n-        raise ArgumentError, 'expires_at is nil' unless expires_at\n         raise ArgumentError, 'nonce is nil' unless nonce\n+        raise ArgumentError, 'signature_method is nil' unless signature_method","path":"lib/cerner/oauth1a/access_token.rb","position":114,"original_position":114,"commit_id":"5ee8c8de25cbc844871c29ea0a503576a9390c2b","original_commit_id":"5ee8c8de25cbc844871c29ea0a503576a9390c2b","user":{"login":"nbeyer","id":121554,"avatar_url":"https://avatars1.githubusercontent.com/u/121554?v=4","gravatar_id":"","url":"https://api.github.com/users/nbeyer","html_url":"https://github.com/nbeyer","followers_url":"https://api.github.com/users/nbeyer/followers","following_url":"https://api.github.com/users/nbeyer/following{/other_user}","gists_url":"https://api.github.com/users/nbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/nbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbeyer/subscriptions","organizations_url":"https://api.github.com/users/nbeyer/orgs","repos_url":"https://api.github.com/users/nbeyer/repos","events_url":"https://api.github.com/users/nbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/nbeyer/received_events","type":"User","site_admin":false},"body":"I can do that, but I'm going to leave the 'PLAINTEXT' in the keyword argument, as I like how it documents the default behavior.","created_at":"2018-02-28T16:55:27Z","updated_at":"2018-02-28T16:55:27Z","html_url":"https://github.com/cerner/cerner-oauth1a/pull/2#discussion_r171312685","pull_request_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/comments/171312685"},"html":{"href":"https://github.com/cerner/cerner-oauth1a/pull/2#discussion_r171312685"},"pull_request":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2"}},"in_reply_to_id":171272045},"pull_request":{"url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2","id":171511700,"html_url":"https://github.com/cerner/cerner-oauth1a/pull/2","diff_url":"https://github.com/cerner/cerner-oauth1a/pull/2.diff","patch_url":"https://github.com/cerner/cerner-oauth1a/pull/2.patch","issue_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/2","number":2,"state":"open","locked":false,"title":"Add APIs for Service Provider Use Cases","user":{"login":"nbeyer","id":121554,"avatar_url":"https://avatars1.githubusercontent.com/u/121554?v=4","gravatar_id":"","url":"https://api.github.com/users/nbeyer","html_url":"https://github.com/nbeyer","followers_url":"https://api.github.com/users/nbeyer/followers","following_url":"https://api.github.com/users/nbeyer/following{/other_user}","gists_url":"https://api.github.com/users/nbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/nbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbeyer/subscriptions","organizations_url":"https://api.github.com/users/nbeyer/orgs","repos_url":"https://api.github.com/users/nbeyer/repos","events_url":"https://api.github.com/users/nbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/nbeyer/received_events","type":"User","site_admin":false},"body":"### Summary\r\n* Expand and refactor AccessToken to allow for parsing OAuth requests\r\n  and authenticating them.\r\n* Expand AccessTokenAgent with methods for getting the keys from the\r\n  Access Token Service, which are required for authentication of OAuth\r\n  requests.\r\n* Add a Protocol utility model for encapsulating common OAuth protocol\r\n  needs.\r\n","created_at":"2018-02-26T22:35:08Z","updated_at":"2018-02-28T16:55:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a0227038f177b34b6444e46c272a29529119394","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2/commits","review_comments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2/comments","review_comment_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/2/comments","statuses_url":"https://api.github.com/repos/cerner/cerner-oauth1a/statuses/5ee8c8de25cbc844871c29ea0a503576a9390c2b","head":{"label":"cerner:service_provider_flows","ref":"service_provider_flows","sha":"5ee8c8de25cbc844871c29ea0a503576a9390c2b","user":{"login":"cerner","id":1873208,"avatar_url":"https://avatars1.githubusercontent.com/u/1873208?v=4","gravatar_id":"","url":"https://api.github.com/users/cerner","html_url":"https://github.com/cerner","followers_url":"https://api.github.com/users/cerner/followers","following_url":"https://api.github.com/users/cerner/following{/other_user}","gists_url":"https://api.github.com/users/cerner/gists{/gist_id}","starred_url":"https://api.github.com/users/cerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cerner/subscriptions","organizations_url":"https://api.github.com/users/cerner/orgs","repos_url":"https://api.github.com/users/cerner/repos","events_url":"https://api.github.com/users/cerner/events{/privacy}","received_events_url":"https://api.github.com/users/cerner/received_events","type":"Organization","site_admin":false},"repo":{"id":78053516,"name":"cerner-oauth1a","full_name":"cerner/cerner-oauth1a","owner":{"login":"cerner","id":1873208,"avatar_url":"https://avatars1.githubusercontent.com/u/1873208?v=4","gravatar_id":"","url":"https://api.github.com/users/cerner","html_url":"https://github.com/cerner","followers_url":"https://api.github.com/users/cerner/followers","following_url":"https://api.github.com/users/cerner/following{/other_user}","gists_url":"https://api.github.com/users/cerner/gists{/gist_id}","starred_url":"https://api.github.com/users/cerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cerner/subscriptions","organizations_url":"https://api.github.com/users/cerner/orgs","repos_url":"https://api.github.com/users/cerner/repos","events_url":"https://api.github.com/users/cerner/events{/privacy}","received_events_url":"https://api.github.com/users/cerner/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cerner/cerner-oauth1a","description":"Cerner OAuth 1.0a Client Library","fork":false,"url":"https://api.github.com/repos/cerner/cerner-oauth1a","forks_url":"https://api.github.com/repos/cerner/cerner-oauth1a/forks","keys_url":"https://api.github.com/repos/cerner/cerner-oauth1a/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cerner/cerner-oauth1a/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cerner/cerner-oauth1a/teams","hooks_url":"https://api.github.com/repos/cerner/cerner-oauth1a/hooks","issue_events_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/events{/number}","events_url":"https://api.github.com/repos/cerner/cerner-oauth1a/events","assignees_url":"https://api.github.com/repos/cerner/cerner-oauth1a/assignees{/user}","branches_url":"https://api.github.com/repos/cerner/cerner-oauth1a/branches{/branch}","tags_url":"https://api.github.com/repos/cerner/cerner-oauth1a/tags","blobs_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/refs{/sha}","trees_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cerner/cerner-oauth1a/statuses/{sha}","languages_url":"https://api.github.com/repos/cerner/cerner-oauth1a/languages","stargazers_url":"https://api.github.com/repos/cerner/cerner-oauth1a/stargazers","contributors_url":"https://api.github.com/repos/cerner/cerner-oauth1a/contributors","subscribers_url":"https://api.github.com/repos/cerner/cerner-oauth1a/subscribers","subscription_url":"https://api.github.com/repos/cerner/cerner-oauth1a/subscription","commits_url":"https://api.github.com/repos/cerner/cerner-oauth1a/commits{/sha}","git_commits_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/commits{/sha}","comments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/comments{/number}","issue_comment_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/comments{/number}","contents_url":"https://api.github.com/repos/cerner/cerner-oauth1a/contents/{+path}","compare_url":"https://api.github.com/repos/cerner/cerner-oauth1a/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cerner/cerner-oauth1a/merges","archive_url":"https://api.github.com/repos/cerner/cerner-oauth1a/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cerner/cerner-oauth1a/downloads","issues_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues{/number}","pulls_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls{/number}","milestones_url":"https://api.github.com/repos/cerner/cerner-oauth1a/milestones{/number}","notifications_url":"https://api.github.com/repos/cerner/cerner-oauth1a/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cerner/cerner-oauth1a/labels{/name}","releases_url":"https://api.github.com/repos/cerner/cerner-oauth1a/releases{/id}","deployments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/deployments","created_at":"2017-01-04T21:15:45Z","updated_at":"2018-02-26T22:33:49Z","pushed_at":"2018-02-26T22:35:08Z","git_url":"git://github.com/cerner/cerner-oauth1a.git","ssh_url":"git@github.com:cerner/cerner-oauth1a.git","clone_url":"https://github.com/cerner/cerner-oauth1a.git","svn_url":"https://github.com/cerner/cerner-oauth1a","homepage":"","size":37,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"cerner:master","ref":"master","sha":"bc6b908402796e53cd46047ca20c02070b9fdcaa","user":{"login":"cerner","id":1873208,"avatar_url":"https://avatars1.githubusercontent.com/u/1873208?v=4","gravatar_id":"","url":"https://api.github.com/users/cerner","html_url":"https://github.com/cerner","followers_url":"https://api.github.com/users/cerner/followers","following_url":"https://api.github.com/users/cerner/following{/other_user}","gists_url":"https://api.github.com/users/cerner/gists{/gist_id}","starred_url":"https://api.github.com/users/cerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cerner/subscriptions","organizations_url":"https://api.github.com/users/cerner/orgs","repos_url":"https://api.github.com/users/cerner/repos","events_url":"https://api.github.com/users/cerner/events{/privacy}","received_events_url":"https://api.github.com/users/cerner/received_events","type":"Organization","site_admin":false},"repo":{"id":78053516,"name":"cerner-oauth1a","full_name":"cerner/cerner-oauth1a","owner":{"login":"cerner","id":1873208,"avatar_url":"https://avatars1.githubusercontent.com/u/1873208?v=4","gravatar_id":"","url":"https://api.github.com/users/cerner","html_url":"https://github.com/cerner","followers_url":"https://api.github.com/users/cerner/followers","following_url":"https://api.github.com/users/cerner/following{/other_user}","gists_url":"https://api.github.com/users/cerner/gists{/gist_id}","starred_url":"https://api.github.com/users/cerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cerner/subscriptions","organizations_url":"https://api.github.com/users/cerner/orgs","repos_url":"https://api.github.com/users/cerner/repos","events_url":"https://api.github.com/users/cerner/events{/privacy}","received_events_url":"https://api.github.com/users/cerner/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cerner/cerner-oauth1a","description":"Cerner OAuth 1.0a Client Library","fork":false,"url":"https://api.github.com/repos/cerner/cerner-oauth1a","forks_url":"https://api.github.com/repos/cerner/cerner-oauth1a/forks","keys_url":"https://api.github.com/repos/cerner/cerner-oauth1a/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cerner/cerner-oauth1a/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cerner/cerner-oauth1a/teams","hooks_url":"https://api.github.com/repos/cerner/cerner-oauth1a/hooks","issue_events_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/events{/number}","events_url":"https://api.github.com/repos/cerner/cerner-oauth1a/events","assignees_url":"https://api.github.com/repos/cerner/cerner-oauth1a/assignees{/user}","branches_url":"https://api.github.com/repos/cerner/cerner-oauth1a/branches{/branch}","tags_url":"https://api.github.com/repos/cerner/cerner-oauth1a/tags","blobs_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/refs{/sha}","trees_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cerner/cerner-oauth1a/statuses/{sha}","languages_url":"https://api.github.com/repos/cerner/cerner-oauth1a/languages","stargazers_url":"https://api.github.com/repos/cerner/cerner-oauth1a/stargazers","contributors_url":"https://api.github.com/repos/cerner/cerner-oauth1a/contributors","subscribers_url":"https://api.github.com/repos/cerner/cerner-oauth1a/subscribers","subscription_url":"https://api.github.com/repos/cerner/cerner-oauth1a/subscription","commits_url":"https://api.github.com/repos/cerner/cerner-oauth1a/commits{/sha}","git_commits_url":"https://api.github.com/repos/cerner/cerner-oauth1a/git/commits{/sha}","comments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/comments{/number}","issue_comment_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/comments{/number}","contents_url":"https://api.github.com/repos/cerner/cerner-oauth1a/contents/{+path}","compare_url":"https://api.github.com/repos/cerner/cerner-oauth1a/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cerner/cerner-oauth1a/merges","archive_url":"https://api.github.com/repos/cerner/cerner-oauth1a/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cerner/cerner-oauth1a/downloads","issues_url":"https://api.github.com/repos/cerner/cerner-oauth1a/issues{/number}","pulls_url":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls{/number}","milestones_url":"https://api.github.com/repos/cerner/cerner-oauth1a/milestones{/number}","notifications_url":"https://api.github.com/repos/cerner/cerner-oauth1a/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cerner/cerner-oauth1a/labels{/name}","releases_url":"https://api.github.com/repos/cerner/cerner-oauth1a/releases{/id}","deployments_url":"https://api.github.com/repos/cerner/cerner-oauth1a/deployments","created_at":"2017-01-04T21:15:45Z","updated_at":"2018-02-26T22:33:49Z","pushed_at":"2018-02-26T22:35:08Z","git_url":"git://github.com/cerner/cerner-oauth1a.git","ssh_url":"git@github.com:cerner/cerner-oauth1a.git","clone_url":"https://github.com/cerner/cerner-oauth1a.git","svn_url":"https://github.com/cerner/cerner-oauth1a","homepage":"","size":37,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2"},"html":{"href":"https://github.com/cerner/cerner-oauth1a/pull/2"},"issue":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/2"},"comments":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/cerner/cerner-oauth1a/statuses/5ee8c8de25cbc844871c29ea0a503576a9390c2b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"nbeyer"}}