Movatterモバイル変換


[0]ホーム

URL:


jws

package
v0.34.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2025 License:BSD-3-ClauseImports:11Imported by:998

Details

Repository

cs.opensource.google/go/x/oauth2

Links

Documentation

Overview

Package jws provides a partial implementationof JSON Web Signature encoding and decoding.It exists to support thegolang.org/x/oauth2 package.

SeeRFC 7515.

Deprecated: this package is not intended for public use and might beremoved in the future. It exists for internal use only.Please switch to another JWS package or copy this package into your ownsource tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcEncode

func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string,error)

Encode encodes a signed JWS with provided header and claim set.This invokesEncodeWithSigner usingcrypto/rsa.SignPKCS1v15 with the given RSA private key.

funcEncodeWithSigner

func EncodeWithSigner(header *Header, c *ClaimSet, sgSigner) (string,error)

EncodeWithSigner encodes a header and claim set with the provided signer.

funcVerify

func Verify(tokenstring, key *rsa.PublicKey)error

Verify tests whether the provided JWT token's signature was produced by the private keyassociated with the supplied public key.

Types

typeClaimSet

type ClaimSet struct {Issstring `json:"iss"`// email address of the client_id of the application making the access token requestScopestring `json:"scope,omitempty"`// space-delimited list of the permissions the application requestsAudstring `json:"aud"`// descriptor of the intended target of the assertion (Optional).Expint64  `json:"exp"`// the expiration time of the assertion (seconds since Unix epoch)Iatint64  `json:"iat"`// the time the assertion was issued (seconds since Unix epoch)Typstring `json:"typ,omitempty"`// token type (Optional).// Email for which the application is requesting delegated access (Optional).Substring `json:"sub,omitempty"`// The old name of Sub. Client keeps setting Prn to be// complaint with legacy OAuth 2.0 providers. (Optional)Prnstring `json:"prn,omitempty"`// Seehttp://tools.ietf.org/html/draft-jones-json-web-token-10#section-4.3// This array is marshalled using custom code (see (c *ClaimSet) encode()).PrivateClaims map[string]any `json:"-"`}

ClaimSet contains information about the JWT signature including thepermissions being requested (scopes), the target of the token, the issuer,the time the token was issued, and the lifetime of the token.

funcDecode

func Decode(payloadstring) (*ClaimSet,error)

Decode decodes a claim set from a JWS payload.

typeHeader

type Header struct {// The algorithm used for signature.Algorithmstring `json:"alg"`// Represents the token type.Typstring `json:"typ"`// The optional hint of which key is being used.KeyIDstring `json:"kid,omitempty"`}

Header represents the header for the signed JWS payloads.

typeSigner

type Signer func(data []byte) (sig []byte, errerror)

Signer returns a signature for the given data.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp