Documentation
¶
Index ¶
- Constants
- func Configure(c Config)
- func CreateTelegramLoginToken(secret, where string) (string, error)
- func IsTelegramLoginToken(token string) bool
- func NewTelegramLoginSecret() (string, error)
- func ParseTelegramLoginToken(token string) (tenantDir string, ok bool)
- func PollTelegramLogin(token, secret string) (status string, userID int64)
- func ProcessTelegramLoginConfirm(token string, chatID int64, langHint string) (owned bool, reply string)
- func ProcessTelegramLoginStart(token string, chatID int64, chatType, langHint string) (owned bool, reply, confirm, confirmLabel string)
- func TelegramTokenTenant(token string) (dir string, named bool)
- type Config
- type HTTPConfig
- type Subject
Constants ¶
const ( TelegramLoginPrefix = "login_" TelegramLinkPrefix = "link_" )
const PollSecretHeader = "X-Login-Secret"
Variables ¶
This section is empty.
Functions ¶
func CreateTelegramLoginToken ¶
CreateTelegramLoginToken issues a sign-in token bound to secret. where is shown to the person in the confirmation message.
func IsTelegramLoginToken ¶
IsTelegramLoginToken reports whether a /start payload is a sign-in token.
func NewTelegramLoginSecret ¶
NewTelegramLoginSecret returns the page-held secret that polls must present.
func ParseTelegramLoginToken ¶
ParseTelegramLoginToken returns the tenant a sign-in token was issued by.
func PollTelegramLogin ¶
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 ¶
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 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)