telegramlogin

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelegramLoginPrefix = "login_"
	TelegramLinkPrefix  = "link_"
)
View Source
const PollSecretHeader = "X-Login-Secret"

Variables

This section is empty.

Functions

func Configure

func Configure(c Config)

func CreateTelegramLoginToken

func CreateTelegramLoginToken(secret, where string) (string, error)

CreateTelegramLoginToken issues a sign-in token bound to secret. where is shown to the person in the confirmation message.

func IsTelegramLoginToken

func IsTelegramLoginToken(token string) bool

IsTelegramLoginToken reports whether a /start payload is a sign-in token.

func NewTelegramLoginSecret

func NewTelegramLoginSecret() (string, error)

NewTelegramLoginSecret returns the page-held secret that polls must present.

func ParseTelegramLoginToken

func ParseTelegramLoginToken(token string) (tenantDir string, ok bool)

ParseTelegramLoginToken returns the tenant a sign-in token was issued by.

func PollTelegramLogin

func PollTelegramLogin(token, secret string) (status string, userID int64)

PollTelegramLogin reports where a sign-in stands for the page that holds the secret: pending, awaiting (the person has been asked to confirm), approved (the token is consumed and userID is who to sign in), rejected or expired.

func ProcessTelegramLoginConfirm

func ProcessTelegramLoginConfirm(token string, chatID int64, langHint string) (owned bool, reply string)

ProcessTelegramLoginConfirm handles the confirm button. Only the chat the start came from can approve it.

func ProcessTelegramLoginStart

func ProcessTelegramLoginStart(token string, chatID int64, chatType, langHint string) (owned bool, reply, confirm, confirmLabel string)

ProcessTelegramLoginStart handles the bot's /start <token>. owned is false when this tenant has no such pending sign-in. confirm and confirmLabel are set when the person must confirm with the button; reply is the message to send either way. Only an enabled admin or staff account linked to this Telegram account can sign in.

func TelegramTokenTenant

func TelegramTokenTenant(token string) (dir string, named bool)

TelegramTokenTenant reports which tenant issued a /start token. named is true for sign-in and account-link tokens; dir is empty when such a token is malformed. A bare /start or any other payload is not named.

Types

type Config

type Config struct {
	OwnDirName func() string
	FindUsers  func(chatID int64) ([]int64, error)
	Text       func(langHint, key string) string
}

type HTTPConfig

type HTTPConfig struct {
	BotUsername  func() string
	Where        func(r *http.Request) string
	LookupUser   func(id int64) (Subject, error)
	LogSignIn    func(r *http.Request, s Subject)
	Temp2FAToken func(userID int64) (string, error)
	Finalize     func(w http.ResponseWriter, r *http.Request, s Subject)
	TwoFAPath    string
}

func (HTTPConfig) HandlePoll

func (c HTTPConfig) HandlePoll(w http.ResponseWriter, r *http.Request)

func (HTTPConfig) HandleStart

func (c HTTPConfig) HandleStart(w http.ResponseWriter, r *http.Request)

type Subject

type Subject struct {
	ID       int64
	Disabled bool
	TwoFA    bool
	Payload  any
}

Jump to

Keyboard shortcuts

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