oauth

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const NativeRedirectURI = "jms://auth/callback"

Variables

This section is empty.

Functions

func ParseCallback

func ParseCallback(request *http.Request, expectedState string) (string, error)

func ParseCallbackURL

func ParseCallbackURL(rawURL, expectedRedirectURI, expectedState string) (string, error)

ParseCallbackURL 接受原生回调本身,或 next 参数中包含原生回调的 JumpServer 确认页 URL。

Types

type Authorization

type Authorization struct {
	URL      string
	State    string
	Verifier string
}

func NewAuthorization

func NewAuthorization(metadata Metadata, redirectURI string, random io.Reader) (Authorization, error)

type Client

type Client struct {
	HTTPClient *http.Client
	Metadata   Metadata
}

func (Client) Exchange

func (c Client) Exchange(ctx context.Context, code, verifier, redirectURI string) (TokenResponse, error)

func (Client) Refresh

func (c Client) Refresh(ctx context.Context, refreshToken string) (TokenResponse, error)

func (Client) Revoke

func (c Client) Revoke(ctx context.Context, token string) error

type ManualAuthorization

type ManualAuthorization struct {
	URL string
	// contains filtered or unexported fields
}

func BeginManualAuthorization

func BeginManualAuthorization(ctx context.Context, httpClient *http.Client, site, redirectURI string) (ManualAuthorization, error)

func (ManualAuthorization) Complete

func (a ManualAuthorization) Complete(ctx context.Context, rawCallback string, now time.Time) (credential.Token, error)

type ManualFlow

type ManualFlow struct {
	HTTPClient  *http.Client
	RedirectURI string
	OpenBrowser func(string) error
	NoBrowser   bool
	Input       io.Reader
	Output      io.Writer
	Now         func() time.Time
}

ManualFlow 读取用户粘贴的 URL 来完成原生 OAuth 回调。 当其他程序占用 jms scheme 或系统禁止注册私有协议时,它也是长期保留的回退方式。

func (ManualFlow) Login

func (f ManualFlow) Login(ctx context.Context, site string) (credential.Token, error)

type Metadata

type Metadata struct {
	Issuer                string `json:"issuer"`
	ClientID              string `json:"client_id"`
	AuthorizationEndpoint string `json:"authorization_endpoint"`
	TokenEndpoint         string `json:"token_endpoint"`
	RevocationEndpoint    string `json:"revocation_endpoint"`
}

func Discover

func Discover(ctx context.Context, client *http.Client, site string) (Metadata, error)

type TokenEndpointError

type TokenEndpointError struct {
	Code       string
	StatusCode int
}

func (*TokenEndpointError) Error

func (e *TokenEndpointError) Error() string

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
}

func (TokenResponse) Record

func (t TokenResponse) Record(clientID, site string, now time.Time) (credential.Token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL