api

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIAccountAuthConfig = mwapp.NewAuthConfig().SetSecretGetter(func(ctx echo.Context, appID string) (string, error) {
	m := NewAccount(ctx)
	err := m.Get(nil, `app_id`, appID)
	if err != nil {
		if err == db.ErrNoMoreRows {
			err = ctx.NewError(code.DataNotFound, `API账号“%s”没找到`, appID).SetZone(`appId`)
		}
		return "", err
	}

	if m.Disabled != `N` {
		return "", ctx.NewError(code.DataUnavailable, `API账号“%s”已经停用`, appID).SetZone(`appId`)
	}
	ctx.Internal().Store(`ApiAccount`, m.OfficialCommonApiAccount)
	return m.AppSecret, nil
})

APIAccountAuthConfig Api账号认证配置

View Source
var APIAuthMiddleware = mwapp.Auth(*APIAccountAuthConfig)

APIAuthMiddleware Api账号认证中间件

Functions

This section is empty.

Types

type Account

type Account struct {
	*dbschema.OfficialCommonApiAccount
}

func NewAccount

func NewAccount(ctx echo.Context) *Account

func (*Account) Add

func (f *Account) Add() (pk interface{}, err error)

func (*Account) Edit

func (f *Account) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Account) Exists

func (f *Account) Exists(appId string) error

func (*Account) ExistsOther

func (f *Account) ExistsOther(appId string, id uint64) error

func (*Account) GetByAppID

func (f *Account) GetByAppID(appID string) (*dbschema.OfficialCommonApiAccount, error)

func (*Account) OauthLogin

func (f *Account) OauthLogin() echo.H

func (*Account) ParseExtra

func (f *Account) ParseExtra() echo.H

Jump to

Keyboard shortcuts

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