Documentation
¶
Index ¶
- type Handler
- func (h *Handler) Accept(c *echo.Context) error
- func (h *Handler) GenToken(c *echo.Context) error
- func (h *Handler) MiAuthCheck(c *echo.Context) error
- func (h *Handler) SessionGenerate(c *echo.Context) error
- func (h *Handler) SessionShow(c *echo.Context) error
- func (h *Handler) SessionUserkey(c *echo.Context) error
- func (h *Handler) SetTokenNotifier(n TokenNotifier)
- func (h *Handler) SetUserRepo(r repository.UserRepository)
- type TokenNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles MiAuth endpoints.
func NewHandler ¶
func NewHandler(repo repository.AuthSessionRepository, cfg *config.Config, idGen id.Generator, entityPacker *entity.Packer, detailExtras userpack.DetailExtras, background *bgwork.Group) *Handler
NewHandler creates a new auth handler. entityPacker is the Packer this handler packs entities with (#3792); detailExtras fills pinnedNotes / pinnedPage / movedTo / alsoKnownAs for auth/session/userkey and the miauth check (#3330); background is the group the work after a response runs in, so stopping the server generation waits for it (#3661).
func (*Handler) GenToken ¶
GenToken handles POST /api/miauth/gen-token. MiAuth用のアクセストークンを直接生成する(App不要)。
func (*Handler) MiAuthCheck ¶
MiAuthCheck handles POST /api/miauth/:session/check.
3rd-party クライアントは MiAuth 承認 (= GenToken で session 紐付き access token 作成) 後、本 endpoint を polling して token を取得する。upstream ApiServerService の /miauth/:session/check 相当: session に対応する未取得の token があれば fetched=true にして {ok, token, user} を返し、無ければ {ok:false} を返す。認証不要 (token をまだ持たない client が叩くため)。
func (*Handler) SessionGenerate ¶
SessionGenerate handles POST /api/auth/session/generate.
func (*Handler) SessionShow ¶
SessionShow handles POST /api/auth/session/show.
func (*Handler) SessionUserkey ¶
SessionUserkey handles POST /api/auth/session/userkey.
func (*Handler) SetTokenNotifier ¶
func (h *Handler) SetTokenNotifier(n TokenNotifier)
SetTokenNotifier attaches a TokenNotifier so gen-token creates a 'createToken' notification (upstream miauth/gen-token)。
func (*Handler) SetUserRepo ¶
func (h *Handler) SetUserRepo(r repository.UserRepository)
SetUserRepo wires the user repository used by MiAuthCheck to pack the approving user.
type TokenNotifier ¶
type TokenNotifier interface {
OnCreateToken(userID string)
}
TokenNotifier records a 'createToken' notification when a token is generated (#1559)。循環依存を避けるため interface で受け取る (実装は core/notification.Hook)。