sessiontoken

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 6 Imported by: ? 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

Overview

Package sessiontoken 签发和验证绑定到一个会话的令牌。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Issue

func Issue(secret string, conversationID defs.ConversationID, sessionID defs.SessionID) string

Issue 用 serve 的令牌签发会话 Token。

func Verify

func Verify(secret, token string) (defs.ConversationID, defs.SessionID, bool)

Verify 验证会话 Token 并返回它绑定的两个 ID。

Types

type Secret

type Secret struct {
	// contains filtered or unexported fields
}

Secret 保存当前操作者令牌,运行中的会话签发时读取同一份密钥。

func NewSecret

func NewSecret(token string) *Secret

NewSecret 用当前操作者令牌初始化会话签发与验证共用的密钥。

func (*Secret) GetToken

func (s *Secret) GetToken() string

GetToken 返回当前操作者令牌;未配置密钥时返回空串。

func (*Secret) Replace

func (s *Secret) Replace(token string)

Replace 更新密钥,后续签发和验证使用新令牌。

Jump to

Keyboard shortcuts

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