jwt/search/search_index.json

1 line
16 KiB
JSON
Raw Normal View History

{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Getting Started","text":"<p>Welcome to <code>jwt-go</code>, a go (or 'golang' for search engine friendliness) implementation of JSON Web Tokens. </p>"},{"location":"#supported-go-versions","title":"Supported Go versions","text":"<p>Our support of Go versions is aligned with Go's version release policy. So we will support a major version of Go until there are two newer major releases. We no longer support building jwt-go with unsupported Go versions, as these contain security vulnerabilities which will not be fixed.</p>"},{"location":"#what-the-heck-is-a-jwt","title":"What the heck is a JWT?","text":"<p>JWT.io has a great introduction to JSON Web Tokens.</p> <p>In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for <code>Bearer</code> tokens in OAuth 2.0 A token is made of three parts, separated by <code>.</code>'s. The first two parts are JSON objects, that have been base64url encoded. The last part is the signature, encoded the same way.</p> <p>The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used.</p> <p>The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to RFC 7519 for information about reserved keys and the proper way to add your own.</p>"},{"location":"#whats-in-the-box","title":"What's in the box?","text":"<p>This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, ECDSA and EdDSA, though hooks are present for adding your own.</p>"},{"location":"#installation-guidelines","title":"Installation Guidelines","text":"<p>To install the jwt package, you first need to have Go installed, then you can use the command below to add <code>jwt-go</code> as a dependency in your Go program.</p> <pre><code>go get -u github.com/golang-jwt/jwt/v5\n</code></pre> <p>Then import it in your code:</p> <pre><code>import \"github.com/golang-jwt/jwt/v5\"\n</code></pre>"},{"location":"#jwt-and-oauth-20","title":"JWT and OAuth 2.0","text":"<p>It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication.</p> <p>Without going too far down the rabbit hole, here's a description of the interaction of these technologies:</p> <ul> <li>OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth.</li> <li>OAuth defines several options for passing around authentication data. One popular method is called a \"bearer token\". A bearer token is simply a string that should only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token. This is also specified in the JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens, detailed in RFC 9068.</li> <li>Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over TLS.</li> </ul>"},{"location":"usage/create/","title":"Creating a New JWT","text":"<p>One of the primary goals of this library is to create a new JWT (or in short token).</p>"},{"location":"usage/create/#with-default-options","title":"With Default Options","text":"<p>The easiest way to create a token is to use the <code>jwt.New</code> function. It then needs one of the available signing methods, to finally sign and convert the token into a string format (using the <code>SignedString</code> m