mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-27 10:34:42 -05:00
Renewals without a valid session only need the share id, so they no longer cancel a link the guest hasn't used yet.
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
// Copyright 2026 OpenCloud GmbH <mail@opencloud.eu>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package authguest
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/opencloud-eu/opencloud/services/auth-guest/pkg/service/guard"
|
|
)
|
|
|
|
var (
|
|
ErrExpired = errors.New("token expired")
|
|
ErrAlreadyRedeemed = errors.New("token already redeemed")
|
|
ErrShareNotFound = errors.New("share not found")
|
|
ErrShareExpired = errors.New("share expired")
|
|
ErrEventsNotConfigured = errors.New("event publisher not configured")
|
|
ErrPinInvalid = errors.New("pin invalid")
|
|
ErrPinExpired = errors.New("pin expired")
|
|
ErrNonceInvalid = errors.New("nonce invalid")
|
|
ErrNonceExpired = errors.New("nonce expired")
|
|
ErrTooManyAttempts = errors.New("too many attempts")
|
|
ErrPermissionMismatch = errors.New("permissionId does not match the provided credentials")
|
|
|
|
// errLinkRedeemable aborts a renewal without a valid session because the
|
|
// newest link can still be redeemed. Renew reports it as success.
|
|
errLinkRedeemable = errors.New("newest guest link can still be redeemed")
|
|
)
|
|
|
|
// GuestError wraps an auth-guest failure together with the share id. The HTTP
|
|
// transport inspects ErrorType to choose a status code and message.
|
|
type GuestError struct {
|
|
ErrorType error
|
|
ShareID string
|
|
RetryAfter time.Duration
|
|
}
|
|
|
|
func (e *GuestError) Error() string { return e.ErrorType.Error() }
|
|
|
|
func nonceError(err error) error {
|
|
if errors.Is(err, guard.ErrNonceExpired) {
|
|
return ErrNonceExpired
|
|
}
|
|
return ErrNonceInvalid
|
|
}
|