2026-08-29 07:09:04 -07:00
|
|
|
package handler
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
"github.com/warmbly/warmbly/internal/api/middleware"
|
|
|
|
|
"github.com/warmbly/warmbly/internal/errx"
|
|
|
|
|
"github.com/warmbly/warmbly/internal/models"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Self-hosted side of the warmup pool link: Settings > Warmbly Cloud.
|
|
|
|
|
|
|
|
|
|
func (h *Handler) cloudLinkReady(c *gin.Context) bool {
|
|
|
|
|
if h.CloudLinkService == nil {
|
feat: complete the ADA CASA v2.1.1 AL1 control set across authentication, sessions, access control, cryptography, input validation and configuration, adding a breached-password denylist and per-account login throttling, enforced multi-factor authentication on the admin panel, step-up confirmation before an action that mints a lasting credential, purpose-scoped session tokens, single-use TOTP steps, tenant verification on every cross-referenced identifier, security headers on every surface, encrypted webhook signing secrets, per-organization idempotency, PKCE and a minimal two-scope Gmail consent on the mailbox OAuth flow, bounded spreadsheet and archive decoding, a patched Go toolchain with govulncheck in CI, and the evidence pack under compliance/casa
2026-09-19 08:18:35 +02:00
|
|
|
errx.JSON(c, errx.New(errx.NotImplemented, "cloud link is not enabled on this instance"))
|
2026-08-29 07:09:04 -07:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkStatus(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
st, xerr := h.CloudLinkService.Status(c.Request.Context(), *orgID)
|
2026-08-29 07:09:04 -07:00
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, st)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkConnectStart(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-08-29 07:09:04 -07:00
|
|
|
userID, err := middleware.GetUserUUID(c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrUnauthorized)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var req struct {
|
|
|
|
|
CloudURL string `json:"cloud_url"`
|
|
|
|
|
}
|
|
|
|
|
_ = c.ShouldBindJSON(&req)
|
2026-10-07 13:49:42 +00:00
|
|
|
p, xerr := h.CloudLinkService.StartConnect(c.Request.Context(), *orgID, userID, req.CloudURL)
|
2026-08-29 07:09:04 -07:00
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusCreated, p)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkConnectPoll(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-08-29 07:09:04 -07:00
|
|
|
userID, err := middleware.GetUserUUID(c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrUnauthorized)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
res, xerr := h.CloudLinkService.PollConnect(c.Request.Context(), *orgID, userID)
|
2026-08-29 07:09:04 -07:00
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if res.Status == models.PoolLinkCodeApproved && res.Link != nil {
|
|
|
|
|
h.auditOrg(c, models.AuditActionConnect, models.AuditEntityCloudLink, &res.Link.InstanceID, nil, map[string]string{"organization_name": res.Link.OrganizationName})
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, res)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkDisconnect(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if xerr := h.CloudLinkService.Disconnect(c.Request.Context(), *orgID, c.Query("legacy") == "true"); xerr != nil {
|
2026-08-29 07:09:04 -07:00
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionDisconnect, models.AuditEntityCloudLink, nil, nil, nil)
|
|
|
|
|
c.Status(http.StatusNoContent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkMailboxes(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
rows, xerr := h.CloudLinkService.ListMailboxes(c.Request.Context(), *orgID)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"data": rows})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func cloudLinkAccountID(c *gin.Context) (uuid.UUID, *uuid.UUID, bool) {
|
|
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return uuid.Nil, nil, false
|
|
|
|
|
}
|
|
|
|
|
id, err := uuid.Parse(c.Param("id"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrUuid)
|
|
|
|
|
return uuid.Nil, nil, false
|
|
|
|
|
}
|
|
|
|
|
return id, orgID, true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkEnroll(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
id, orgID, ok := cloudLinkAccountID(c)
|
|
|
|
|
if !ok {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
row, xerr := h.CloudLinkService.Enroll(c.Request.Context(), *orgID, id)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionStart, models.AuditEntityCloudLink, &id, nil, map[string]string{"email": row.Email})
|
|
|
|
|
c.JSON(http.StatusOK, row)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkUnenroll(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
id, orgID, ok := cloudLinkAccountID(c)
|
|
|
|
|
if !ok {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if xerr := h.CloudLinkService.Unenroll(c.Request.Context(), *orgID, id); xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionStop, models.AuditEntityCloudLink, &id, nil, nil)
|
|
|
|
|
c.Status(http.StatusNoContent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkPause(c *gin.Context) {
|
|
|
|
|
h.cloudLinkLifecycle(c, "pause", models.AuditActionPause)
|
|
|
|
|
}
|
|
|
|
|
func (h *Handler) CloudLinkResume(c *gin.Context) {
|
|
|
|
|
h.cloudLinkLifecycle(c, "resume", models.AuditActionResume)
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-07 15:12:45 +00:00
|
|
|
func (h *Handler) CloudLinkParticipation(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
id, orgID, ok := cloudLinkAccountID(c)
|
|
|
|
|
if !ok {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var p models.DiagnosticParticipation
|
|
|
|
|
if err := c.ShouldBindJSON(&p); err != nil {
|
|
|
|
|
errx.JSON(c, errx.InvalidBody(err))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
row, xerr := h.CloudLinkService.SetParticipation(c.Request.Context(), *orgID, id, p)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionUpdate, models.AuditEntityCloudLink, &id, nil, nil)
|
|
|
|
|
c.JSON(http.StatusOK, row)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-29 07:09:04 -07:00
|
|
|
func (h *Handler) cloudLinkLifecycle(c *gin.Context, action string, audit models.AuditAction) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
id, orgID, ok := cloudLinkAccountID(c)
|
|
|
|
|
if !ok {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
row, xerr := h.CloudLinkService.SetLifecycle(c.Request.Context(), *orgID, id, action)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, audit, models.AuditEntityCloudLink, &id, nil, nil)
|
|
|
|
|
c.JSON(http.StatusOK, row)
|
|
|
|
|
}
|
feat: let a linked self-hosted instance sign Google and Microsoft mailboxes in through Warmbly Cloud's own OAuth apps and send with cloud-brokered access tokens: the cloud runs the consent (pool_link_mailboxes.managed, brokered state in Redis, the existing /addresses/*/callback completes it and redirects to the instance's /cloud-oauth/done), keeps the refresh grant, mints short-lived tokens at /pool-link/instance/mailboxes/:id/token and refuses them for revoked links, removed, inactive or blocked mailboxes; the instance mirrors such mailboxes without a credential (cloud_link_mailboxes.managed), ships them to the worker as brokered so goog/msgraph init on a token source that pulls from /api/v1/internal/cloud-link/token/:id, lets the consumer ignore cloud warmup tokens for enrolled mailboxes, and can adopt mailboxes connected directly on the workspace; Add account shows the cloud path and the adoptable list, and the Warmbly Cloud guide documents the model
2026-08-29 09:50:52 -07:00
|
|
|
|
|
|
|
|
// Cloud-managed mailboxes: sign in through Warmbly Cloud, adopt workspace mailboxes.
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkOAuthStart(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
userID, err := middleware.GetUserUUID(c)
|
|
|
|
|
if orgID == nil || err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var req struct {
|
|
|
|
|
Provider models.InboxProvider `json:"provider"`
|
|
|
|
|
}
|
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
2026-09-22 20:21:41 -07:00
|
|
|
errx.JSON(c, errx.InvalidBody(err))
|
feat: let a linked self-hosted instance sign Google and Microsoft mailboxes in through Warmbly Cloud's own OAuth apps and send with cloud-brokered access tokens: the cloud runs the consent (pool_link_mailboxes.managed, brokered state in Redis, the existing /addresses/*/callback completes it and redirects to the instance's /cloud-oauth/done), keeps the refresh grant, mints short-lived tokens at /pool-link/instance/mailboxes/:id/token and refuses them for revoked links, removed, inactive or blocked mailboxes; the instance mirrors such mailboxes without a credential (cloud_link_mailboxes.managed), ships them to the worker as brokered so goog/msgraph init on a token source that pulls from /api/v1/internal/cloud-link/token/:id, lets the consumer ignore cloud warmup tokens for enrolled mailboxes, and can adopt mailboxes connected directly on the workspace; Add account shows the cloud path and the adoptable list, and the Warmbly Cloud guide documents the model
2026-08-29 09:50:52 -07:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
res, xerr := h.CloudLinkService.StartOAuth(c.Request.Context(), *orgID, userID, req.Provider)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusCreated, res)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkOAuthFinish(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
userID, err := middleware.GetUserUUID(c)
|
|
|
|
|
if orgID == nil || err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var req struct {
|
|
|
|
|
Session string `json:"session"`
|
|
|
|
|
}
|
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
2026-09-22 20:21:41 -07:00
|
|
|
errx.JSON(c, errx.InvalidBody(err))
|
feat: let a linked self-hosted instance sign Google and Microsoft mailboxes in through Warmbly Cloud's own OAuth apps and send with cloud-brokered access tokens: the cloud runs the consent (pool_link_mailboxes.managed, brokered state in Redis, the existing /addresses/*/callback completes it and redirects to the instance's /cloud-oauth/done), keeps the refresh grant, mints short-lived tokens at /pool-link/instance/mailboxes/:id/token and refuses them for revoked links, removed, inactive or blocked mailboxes; the instance mirrors such mailboxes without a credential (cloud_link_mailboxes.managed), ships them to the worker as brokered so goog/msgraph init on a token source that pulls from /api/v1/internal/cloud-link/token/:id, lets the consumer ignore cloud warmup tokens for enrolled mailboxes, and can adopt mailboxes connected directly on the workspace; Add account shows the cloud path and the adoptable list, and the Warmbly Cloud guide documents the model
2026-08-29 09:50:52 -07:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
acc, xerr := h.CloudLinkService.FinishOAuth(c.Request.Context(), *orgID, userID, req.Session)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionConnect, models.AuditEntityEmailAccount, &acc.ID, nil, map[string]string{"email": acc.Email, "via": "warmbly_cloud"})
|
|
|
|
|
c.JSON(http.StatusCreated, acc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkWorkspaceMailboxes(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-10-07 13:49:42 +00:00
|
|
|
orgID := middleware.GetOrganizationID(c)
|
|
|
|
|
if orgID == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNoOrganization)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
list, xerr := h.CloudLinkService.ListWorkspaceMailboxes(c.Request.Context(), *orgID)
|
feat: let a linked self-hosted instance sign Google and Microsoft mailboxes in through Warmbly Cloud's own OAuth apps and send with cloud-brokered access tokens: the cloud runs the consent (pool_link_mailboxes.managed, brokered state in Redis, the existing /addresses/*/callback completes it and redirects to the instance's /cloud-oauth/done), keeps the refresh grant, mints short-lived tokens at /pool-link/instance/mailboxes/:id/token and refuses them for revoked links, removed, inactive or blocked mailboxes; the instance mirrors such mailboxes without a credential (cloud_link_mailboxes.managed), ships them to the worker as brokered so goog/msgraph init on a token source that pulls from /api/v1/internal/cloud-link/token/:id, lets the consumer ignore cloud warmup tokens for enrolled mailboxes, and can adopt mailboxes connected directly on the workspace; Add account shows the cloud path and the adoptable list, and the Warmbly Cloud guide documents the model
2026-08-29 09:50:52 -07:00
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"data": list})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (h *Handler) CloudLinkAdopt(c *gin.Context) {
|
|
|
|
|
if !h.cloudLinkReady(c) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
id, orgID, ok := cloudLinkAccountID(c)
|
|
|
|
|
if !ok {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
userID, err := middleware.GetUserUUID(c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrUnauthorized)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
acc, xerr := h.CloudLinkService.Adopt(c.Request.Context(), *orgID, userID, id)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
h.auditOrg(c, models.AuditActionConnect, models.AuditEntityEmailAccount, &acc.ID, nil, map[string]string{"email": acc.Email, "via": "warmbly_cloud"})
|
|
|
|
|
c.JSON(http.StatusCreated, acc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// InternalCloudLinkToken is the worker's credential for a managed mailbox.
|
|
|
|
|
//
|
|
|
|
|
// GET /api/v1/internal/cloud-link/token/:id -> 200 {"access_token","expires_at"} | 4xx with the cloud's reason
|
|
|
|
|
func (h *Handler) InternalCloudLinkToken(c *gin.Context) {
|
|
|
|
|
id, err := uuid.Parse(c.Param("id"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
errx.JSON(c, errx.ErrUuid)
|
|
|
|
|
return
|
|
|
|
|
}
|
feat: rebuild mailbox import around column mapping and automatic host and sign-in detection (CSV, XLSX, pasted lists, saved mappings, retryable rows with fixes, migrations 000205-000206), connect whole Google Workspace domains and Microsoft 365 organizations through a proved administrator grant, import from inbox vendors (InboxKit, Zapmail, Mailforge, Infraforge, Maildoso, Cheap Inboxes, ScaledMail) with vendor-managed forwarding and DNS, add a sending domains page with per-domain tracking and verified root redirects, unify Add account into one Google and one Microsoft entry with per-method choices, mark per-mailbox Google sign-in as retiring with in-place moves to the admin grant or an app password, allow the loopback security mode in the credential columns (migration 000207), read semicolon-separated CSVs, and add a mock vendor API to the sandbox
2026-09-23 08:41:01 -07:00
|
|
|
// A mailbox under an administrator's grant is minted for here, not by the cloud.
|
|
|
|
|
if h.DelegationService != nil {
|
|
|
|
|
tok, handled, xerr := h.DelegationService.AccessToken(c.Request.Context(), id)
|
|
|
|
|
if handled {
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.Header("Cache-Control", "no-store")
|
|
|
|
|
c.JSON(http.StatusOK, tok)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if h.CloudLinkService == nil {
|
|
|
|
|
errx.JSON(c, errx.ErrNotFound)
|
|
|
|
|
return
|
|
|
|
|
}
|
feat: let a linked self-hosted instance sign Google and Microsoft mailboxes in through Warmbly Cloud's own OAuth apps and send with cloud-brokered access tokens: the cloud runs the consent (pool_link_mailboxes.managed, brokered state in Redis, the existing /addresses/*/callback completes it and redirects to the instance's /cloud-oauth/done), keeps the refresh grant, mints short-lived tokens at /pool-link/instance/mailboxes/:id/token and refuses them for revoked links, removed, inactive or blocked mailboxes; the instance mirrors such mailboxes without a credential (cloud_link_mailboxes.managed), ships them to the worker as brokered so goog/msgraph init on a token source that pulls from /api/v1/internal/cloud-link/token/:id, lets the consumer ignore cloud warmup tokens for enrolled mailboxes, and can adopt mailboxes connected directly on the workspace; Add account shows the cloud path and the adoptable list, and the Warmbly Cloud guide documents the model
2026-08-29 09:50:52 -07:00
|
|
|
tok, xerr := h.CloudLinkService.AccessToken(c.Request.Context(), id)
|
|
|
|
|
if xerr != nil {
|
|
|
|
|
errx.JSON(c, xerr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
c.Header("Cache-Control", "no-store")
|
|
|
|
|
c.JSON(http.StatusOK, tok)
|
|
|
|
|
}
|