diff --git a/api/auth/center.go b/api/auth/center.go index 1e28168b8..acbaad943 100644 --- a/api/auth/center.go +++ b/api/auth/center.go @@ -116,12 +116,12 @@ func (c *center) parseAuthHeader(header string) (*authHeader, error) { }, nil } -func (a *authHeader) getAddress() (*oid.Address, error) { +func (a *authHeader) getAddress() (oid.Address, error) { var addr oid.Address if err := addr.DecodeString(strings.ReplaceAll(a.AccessKeyID, "0", "/")); err != nil { - return nil, apiErrors.GetAPIError(apiErrors.ErrInvalidAccessKeyID) + return addr, apiErrors.GetAPIError(apiErrors.ErrInvalidAccessKeyID) } - return &addr, nil + return addr, nil } func (c *center) Authenticate(r *http.Request) (*accessbox.Box, error) { @@ -176,7 +176,7 @@ func (c *center) Authenticate(r *http.Request) (*accessbox.Box, error) { return nil, err } - box, err := c.cli.GetBox(r.Context(), *addr) + box, err := c.cli.GetBox(r.Context(), addr) if err != nil { return nil, fmt.Errorf("get box: %w", err) } diff --git a/creds/tokens/credentials.go b/creds/tokens/credentials.go index e6f6666d6..c959d5d70 100644 --- a/creds/tokens/credentials.go +++ b/creds/tokens/credentials.go @@ -19,7 +19,7 @@ type ( // Credentials is a bearer token get/put interface. Credentials interface { GetBox(context.Context, oid.Address) (*accessbox.Box, error) - Put(context.Context, cid.ID, user.ID, *accessbox.AccessBox, uint64, ...*keys.PublicKey) (*oid.Address, error) + Put(context.Context, cid.ID, user.ID, *accessbox.AccessBox, uint64, ...*keys.PublicKey) (oid.Address, error) } cred struct { @@ -117,15 +117,15 @@ func (c *cred) getAccessBox(ctx context.Context, addr oid.Address) (*accessbox.A return &box, nil } -func (c *cred) Put(ctx context.Context, idCnr cid.ID, issuer user.ID, box *accessbox.AccessBox, expiration uint64, keys ...*keys.PublicKey) (*oid.Address, error) { +func (c *cred) Put(ctx context.Context, idCnr cid.ID, issuer user.ID, box *accessbox.AccessBox, expiration uint64, keys ...*keys.PublicKey) (oid.Address, error) { if len(keys) == 0 { - return nil, ErrEmptyPublicKeys + return oid.Address{}, ErrEmptyPublicKeys } else if box == nil { - return nil, ErrEmptyBearerToken + return oid.Address{}, ErrEmptyBearerToken } data, err := box.Marshal() if err != nil { - return nil, fmt.Errorf("marshall box: %w", err) + return oid.Address{}, fmt.Errorf("marshall box: %w", err) } idObj, err := c.neoFS.CreateObject(ctx, PrmObjectCreate{ @@ -136,12 +136,12 @@ func (c *cred) Put(ctx context.Context, idCnr cid.ID, issuer user.ID, box *acces Payload: data, }) if err != nil { - return nil, fmt.Errorf("create object: %w", err) + return oid.Address{}, fmt.Errorf("create object: %w", err) } var addr oid.Address addr.SetObject(idObj) addr.SetContainer(idCnr) - return &addr, nil + return addr, nil }