config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config 用于配置项的各类定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTokens added in v0.6.0

func NewTokens[T token.Claims](u *User, s *web.Server, mod string, db *orm.DB, bc jwt.BuildClaimsFunc[T], jobTitle string) (*token.Tokens[T], error)

NewTokens 从配置中生成 tokens 对象

Types

type Algorithm added in v0.6.0

type Algorithm struct {
	// 算法的类型
	//
	// 有以下可用值:
	//  - hmac
	//  - rsa
	//  - rspss
	//  - ecdsa
	//  - ed25519
	Type string `json:"type" yaml:"type" xml:"type,attr"`

	// 算法的名称
	Name string `json:"name" yaml:"name" xml:"name"`

	// 公钥
	//
	// 如果是 hmac 类型,那么该值必须与 Private 相同
	Public string `json:"public" yaml:"public" xml:"public"`

	// 私钥
	//
	// 如果是 hmac 类型,那么该值必须与 Public 相同
	Private string `json:"private" yaml:"private" xml:"private"`
	// contains filtered or unexported fields
}

type DB

type DB struct {
	// 表示数据库的类型
	//
	// 目前支持以下几种类型:
	//  - sqlite3
	//  - sqlite 纯 Go
	//  - mysql
	//  - mariadb
	//  - postgres
	Type string `yaml:"type" json:"type" xml:"type,attr"`

	// 连接数据库的参数
	DSN string `yaml:"dsn" json:"dsn" xml:"dsn"`
	// contains filtered or unexported fields
}

DB 数据库的配置文件格式

func (*DB) DB

func (conf *DB) DB() *orm.DB

func (*DB) SanitizeConfig

func (conf *DB) SanitizeConfig() *app.ConfigError

type User added in v0.6.0

type User struct {
	// URLPrefix 路由地址的前缀
	URLPrefix string `json:"urlPrefix,omitempty" xml:"urlPrefix,omitempty" yaml:"urlPrefix,omitempty"`

	// access token 的过期时间,单位为秒。
	AccessExpires int `json:"accessExpires,omitempty" xml:"accessExpires,attr,omitempty" yaml:"accessExpires,omitempty"`

	// refresh token 的过期时间,单位为秒。
	RefreshExpires int `json:"refreshExpires,omitempty" xml:"refreshExpires,attr,omitempty" yaml:"refreshExpires,omitempty"`

	// 支持的所有算法
	Algorithms []*Algorithm `json:"algorithms,omitempty" xml:"algorithm,omitempty" yaml:"algorithms,omitempty"`
}

User 带有登录功能的模块配置

func (*User) SanitizeConfig added in v0.6.0

func (o *User) SanitizeConfig() *app.ConfigError

SanitizeConfig 用于检测和修正配置项的内容

Jump to

Keyboard shortcuts

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