Object

io.toolsplus.atlassian.jwt

HttpRequestCanonicalizer

Related Doc: package jwt

Permalink

object HttpRequestCanonicalizer

Instructions for computing the query hash parameter ("qsh") from a HTTP request. -------------------------------------------------------------------------------------

Overview: query hash = hash(canonical-request)

canonical-request = canonical-method + '&' + canonical-URI + '&' + canonical-query-string

1. Compute canonical method. Simply the upper-case of the method name (e.g. "GET", "PUT").

2. Append the character '&'

3. Compute canonical URI. Discard the protocol, server, port, context path and query parameters from the full URL. For requests targeting add-ons discard the baseUrl in the add-on descriptor. (Removing the context path allows a reverse proxy to redirect incoming requests for "jira.example.com/getsomething" to "example.com/jira/getsomething" without breaking authentication. The requester cannot know that the reverse proxy will prepend the context path "/jira" to the originally requested path "/getsomething".) Empty-string is not permitted; use "/" instead. Do not suffix with a '/' character unless it is the only character. Url-encode any '&' characters in the path. E.g. in "http://server:80/some/path/?param=value" the canonical URI is "/some/path" and in "http://server:80" the canonical URI is "/".

4. Append the character '&'.

5. Compute the canonical query string. Sort the query parameters primarily by their percent-encoded names and secondarily by their percent-encoded values. Sorting is by codepoint: sort(["a", "A", "b", "B"]) => ["A", "B", "a", "b"]. For each parameter append its percent-encoded name, the '=' character and then its percent-encoded value. In the case of repeated parameters append the ',' character and subsequent percent-encoded values. Ignore the JWT query string parameter, if present. Some particular values to be aware of: "+" is encoded as "%20", "*" as "%2A" and "~" as "~". (These values used for consistency with OAuth1.) An example: for a GET request to the not-yet-percent-encoded URL "http://localhost:2990/path/to/service?zee_last=param&repeated=parameter 1&first=param& repeated=parameter 2" the canonical request is "GET&/path/to/service&first=param&repeated=parameter%201,parameter%202& zee_last=param".

6. Convert the canonical request string to bytes. The encoding used to represent characters as bytes is UTF-8.

7. Hash the canonical request bytes using the SHA-256 algorithm. E.g. The SHA-256 hash of "foo" is "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae".

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. HttpRequestCanonicalizer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val QueryStringHashClaimName: String

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def canonicalize(request: CanonicalHttpRequest): String

    Permalink

    Assemble the components of the HTTP request into the correct format so that they can be signed or hashed.

    Assemble the components of the HTTP request into the correct format so that they can be signed or hashed.

    request

    CanonicalHttpRequest that provides the necessary components

    returns

    String encoding the canonical form of this request as required for constructing query string hash values

    Exceptions thrown

    UnsupportedEncodingException UnsupportedEncodingException if the java.net.URLEncoder cannot encode the request's field's characters

  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def computeCanonicalRequestHash(request: CanonicalHttpRequest): String

    Permalink

    Canonicalize the given CanonicalHttpRequest and hash it.

    Canonicalize the given CanonicalHttpRequest and hash it. This request hash can be included as a JWT claim to verify that request components are genuine.

    request

    CanonicalHttpRequest to be canonicalized and hashed

    returns

    String hash suitable for use as a JWT claim value

    Exceptions thrown

    NoSuchAlgorithmException if the hashing algorithm does not exist at runtime

    UnsupportedEncodingException if the java.net.URLEncoder cannot encode the request's field's characters

  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  19. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped