s3api: authenticate unsigned requests by a verified client certificate (#12871)

* iam: let an identity name the client certificates it authenticates with

An Identity gets a list of CertificateMatch entries: a URI SAN, a DNS SAN
and a subject CN, every field set having to equal the certificate's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: authenticate an unsigned request by its verified client certificate

With -tlsVerifyClientCert the gateway verifies every client certificate,
but the certificate took no part in naming the identity. A request that
carries no signature or token now authenticates as the identity whose
certificates match the leaf of the chain the gateway verified, and goes
through the same authorization as a signed request from that identity.
Only a verified chain counts. A signature or token still decides the
identity on its own, a certificate matching a disabled identity or more
than one identity is refused, and a certificate matching none leaves the
request anonymous as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: keep certificate identities off the anonymous read paths

AuthWithPublicRead and the deferred anonymous object read classified a
request by its headers alone, so an unsigned request authenticated by its
client certificate would have been authorized as the anonymous principal:
a GET in a private bucket was refused. They now treat a request whose
certificate names an identity like a signed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep a user's certificate mappings when the dashboard edits it

UpdateObjectStoreUser and UpdateUserPolicies save a rebuilt identity, which
left out the certificates, so editing a user's email or policies ended
their certificate authentication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* credential/postgres: store a user's certificate mappings

The PostgreSQL credential store keeps each identity field it knows in its
own column, so certificates were dropped on save and a user configured
there could not authenticate by certificate. Users get a certificates
JSONB column, added to existing tables like policy_names, and every user
query reads or writes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 authored and GitHub committed 2026-11-21 11:07:24 -08:00
1 parent 48f9a1f891
commit f6d2a42265
9 files changed
+637 -325

No files matched your search

+12 -10
View File
@@ -98,11 +98,12 @@ func (s *AdminServer) UpdateObjectStoreUser(username string, req UpdateUserReque
// Create updated identity
updatedIdentity := &iam_pb.Identity{
Name: identity.Name,
Account: identity.Account,
Credentials: identity.Credentials,
Actions: identity.Actions,
PolicyNames: identity.PolicyNames,
Name: identity.Name,
Account: identity.Account,
Credentials: identity.Credentials,
Actions: identity.Actions,
PolicyNames: identity.PolicyNames,
Certificates: identity.Certificates,
}
// Update actions if provided
@@ -421,11 +422,12 @@ func (s *AdminServer) UpdateUserPolicies(username string, actions []string) erro
// Create updated identity with new actions
updatedIdentity := &iam_pb.Identity{
Name: identity.Name,
Account: identity.Account,
Credentials: identity.Credentials,
Actions: actions,
PolicyNames: identity.PolicyNames,
Name: identity.Name,
Account: identity.Account,
Credentials: identity.Credentials,
Actions: actions,
PolicyNames: identity.PolicyNames,
Certificates: identity.Certificates,
}
// Update user using credential manager
+52 -15
View File
@@ -18,7 +18,7 @@ func (store *PostgresStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap
config := &iam_pb.S3ApiConfiguration{}
rows, err := store.db.QueryContext(ctx, "SELECT username, email, account_data, actions, policy_names FROM users")
rows, err := store.db.QueryContext(ctx, "SELECT username, email, account_data, actions, policy_names, certificates FROM users")
if err != nil {
glog.Errorf("credential postgres: LoadConfiguration query failed: %v", err)
return nil, fmt.Errorf("failed to query users: %w", err)
@@ -27,9 +27,9 @@ func (store *PostgresStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap
for rows.Next() {
var username, email string
var accountDataJSON, actionsJSON, policyNamesJSON []byte
var accountDataJSON, actionsJSON, policyNamesJSON, certificatesJSON []byte
if err := rows.Scan(&username, &email, &accountDataJSON, &actionsJSON, &policyNamesJSON); err != nil {
if err := rows.Scan(&username, &email, &accountDataJSON, &actionsJSON, &policyNamesJSON, &certificatesJSON); err != nil {
glog.Errorf("credential postgres: LoadConfiguration scan failed: %v", err)
return nil, fmt.Errorf("failed to scan user row: %w", err)
}
@@ -56,6 +56,12 @@ func (store *PostgresStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap
}
}
if len(certificatesJSON) > 0 {
if err := json.Unmarshal(certificatesJSON, &identity.Certificates); err != nil {
return nil, fmt.Errorf("failed to unmarshal certificates for user %s: %v", username, err)
}
}
credRows, err := store.db.QueryContext(ctx, "SELECT access_key, secret_key FROM credentials WHERE username = $1", username)
if err != nil {
return nil, fmt.Errorf("failed to query credentials for user %s: %v", username, err)
@@ -158,17 +164,26 @@ func (store *PostgresStore) SaveConfiguration(ctx context.Context, config *iam_p
}
}
var certificatesJSON []byte
if identity.Certificates != nil {
certificatesJSON, err = json.Marshal(identity.Certificates)
if err != nil {
return fmt.Errorf("failed to marshal certificates for user %s: %v", identity.Name, err)
}
}
// Upsert user — preserves the row (and its CASCADE dependents) if it already exists
_, err = tx.ExecContext(ctx,
`INSERT INTO users (username, email, account_data, actions, policy_names)
VALUES ($1, $2, $3, $4, $5)
`INSERT INTO users (username, email, account_data, actions, policy_names, certificates)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (username) DO UPDATE SET
email = EXCLUDED.email,
account_data = EXCLUDED.account_data,
actions = EXCLUDED.actions,
policy_names = EXCLUDED.policy_names,
certificates = EXCLUDED.certificates,
updated_at = CURRENT_TIMESTAMP`,
identity.Name, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON))
identity.Name, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON), jsonbParam(certificatesJSON))
if err != nil {
return fmt.Errorf("failed to upsert user %s: %v", identity.Name, err)
}
@@ -298,9 +313,17 @@ func (store *PostgresStore) CreateUser(ctx context.Context, identity *iam_pb.Ide
}
}
var certificatesJSON []byte
if identity.Certificates != nil {
certificatesJSON, err = json.Marshal(identity.Certificates)
if err != nil {
return fmt.Errorf("failed to marshal certificates: %w", err)
}
}
_, err = tx.ExecContext(ctx,
"INSERT INTO users (username, email, account_data, actions, policy_names) VALUES ($1, $2, $3, $4, $5)",
identity.Name, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON))
"INSERT INTO users (username, email, account_data, actions, policy_names, certificates) VALUES ($1, $2, $3, $4, $5, $6)",
identity.Name, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON), jsonbParam(certificatesJSON))
if err != nil {
glog.Errorf("credential postgres: CreateUser insert failed user=%s: %v", identity.Name, err)
return fmt.Errorf("failed to insert user: %w", err)
@@ -331,11 +354,11 @@ func (store *PostgresStore) GetUser(ctx context.Context, username string) (*iam_
}
var email string
var accountDataJSON, actionsJSON, policyNamesJSON []byte
var accountDataJSON, actionsJSON, policyNamesJSON, certificatesJSON []byte
err := store.db.QueryRowContext(ctx,
"SELECT email, account_data, actions, policy_names FROM users WHERE username = $1",
username).Scan(&email, &accountDataJSON, &actionsJSON, &policyNamesJSON)
"SELECT email, account_data, actions, policy_names, certificates FROM users WHERE username = $1",
username).Scan(&email, &accountDataJSON, &actionsJSON, &policyNamesJSON, &certificatesJSON)
if err != nil {
if err == sql.ErrNoRows {
glog.V(2).Infof("credential postgres: GetUser user=%s not found", username)
@@ -367,6 +390,12 @@ func (store *PostgresStore) GetUser(ctx context.Context, username string) (*iam_
}
}
if len(certificatesJSON) > 0 {
if err := json.Unmarshal(certificatesJSON, &identity.Certificates); err != nil {
return nil, fmt.Errorf("failed to unmarshal certificates: %w", err)
}
}
rows, err := store.db.QueryContext(ctx, "SELECT access_key, secret_key FROM credentials WHERE username = $1", username)
if err != nil {
return nil, fmt.Errorf("failed to query credentials: %w", err)
@@ -435,9 +464,17 @@ func (store *PostgresStore) UpdateUser(ctx context.Context, username string, ide
}
}
var certificatesJSON []byte
if identity.Certificates != nil {
certificatesJSON, err = json.Marshal(identity.Certificates)
if err != nil {
return fmt.Errorf("failed to marshal certificates: %w", err)
}
}
_, err = tx.ExecContext(ctx,
"UPDATE users SET email = $2, account_data = $3, actions = $4, policy_names = $5, updated_at = CURRENT_TIMESTAMP WHERE username = $1",
username, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON))
"UPDATE users SET email = $2, account_data = $3, actions = $4, policy_names = $5, certificates = $6, updated_at = CURRENT_TIMESTAMP WHERE username = $1",
username, "", jsonbParam(accountDataJSON), jsonbParam(actionsJSON), jsonbParam(policyNamesJSON), jsonbParam(certificatesJSON))
if err != nil {
glog.Errorf("credential postgres: UpdateUser failed user=%s: %v", username, err)
return fmt.Errorf("failed to update user: %w", err)
@@ -535,8 +572,8 @@ func (store *PostgresStore) RenameUser(ctx context.Context, oldName, newName str
}
if _, err := tx.ExecContext(ctx,
`INSERT INTO users (username, email, account_data, actions, policy_names, created_at, updated_at)
SELECT $1, email, account_data, actions, policy_names, created_at, CURRENT_TIMESTAMP
`INSERT INTO users (username, email, account_data, actions, policy_names, certificates, created_at, updated_at)
SELECT $1, email, account_data, actions, policy_names, certificates, created_at, CURRENT_TIMESTAMP
FROM users WHERE username = $2`,
newName, oldName); err != nil {
return fmt.Errorf("failed to insert renamed user %s: %w", newName, err)
@@ -131,6 +131,7 @@ func (store *PostgresStore) createTables() error {
account_data JSONB,
actions JSONB,
policy_names JSONB DEFAULT '[]',
certificates JSONB DEFAULT '[]',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
@@ -141,6 +142,10 @@ func (store *PostgresStore) createTables() error {
ALTER TABLE users ADD COLUMN IF NOT EXISTS policy_names JSONB DEFAULT '[]';
`
addCertificatesColumn := `
ALTER TABLE users ADD COLUMN IF NOT EXISTS certificates JSONB DEFAULT '[]';
`
credentialsTable := `
CREATE TABLE IF NOT EXISTS credentials (
id SERIAL PRIMARY KEY,
@@ -216,6 +221,10 @@ func (store *PostgresStore) createTables() error {
return fmt.Errorf("failed to add policy_names column: %w", err)
}
if _, err := store.db.Exec(addCertificatesColumn); err != nil {
return fmt.Errorf("failed to add certificates column: %w", err)
}
if _, err := store.db.Exec(credentialsTable); err != nil {
return fmt.Errorf("failed to create credentials table: %w", err)
}
+9
View File
@@ -202,6 +202,15 @@ message Identity {
repeated string policy_names = 7;
bool is_static = 8; // Loaded from static config file (read-only, not editable via API)
repeated UserTag tags = 9;
repeated CertificateMatch certificates = 10; // client certificates the S3 gateway verified that authenticate as this identity
}
// CertificateMatch matches a verified client certificate when every field set
// equals the certificate's value; a match with no field set matches nothing.
message CertificateMatch {
string uri_san = 1;
string dns_san = 2;
string subject_cn = 3;
}
message UserTag {
+370 -291
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,113 @@
package s3api
import (
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/gorilla/mux"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const certificateIdentityConfig = `{
"identities": [
{"name": "anonymous", "actions": ["Read:public"]},
{"name": "ingest-writer", "certificates": [{"uriSan": "spiffe://example.org/ns/ingest/sa/writer"}], "actions": ["Write:ingest"]},
{"name": "by-cn", "certificates": [{"subjectCn": "reporter", "dnsSan": "reporter.example.internal"}], "actions": ["Read:reports"]},
{"name": "retired", "disabled": true, "certificates": [{"subjectCn": "retired"}], "actions": ["Read:reports"]},
{"name": "twin-a", "certificates": [{"subjectCn": "twin"}], "actions": ["Read:reports"]},
{"name": "twin-b", "certificates": [{"subjectCn": "twin"}], "actions": ["Read:reports"]},
{"name": "empty-match", "certificates": [{}], "actions": ["Admin"]},
{"name": "signer", "credentials": [{"accessKey": "AKIDSIGNER", "secretKey": "secret"}], "actions": ["Admin"]}
]
}`
func clientCertificate(cn string, uri string, dnsNames ...string) *x509.Certificate {
cert := &x509.Certificate{Subject: pkix.Name{CommonName: cn}, DNSNames: dnsNames}
if uri != "" {
u, _ := url.Parse(uri)
cert.URIs = []*url.URL{u}
}
return cert
}
func requestWithClientCertificate(cert *x509.Certificate, verified bool) *http.Request {
r := httptest.NewRequest(http.MethodGet, "https://localhost:8333/ingest/object", nil)
r.TLS = &tls.ConnectionState{PeerCertificates: []*x509.Certificate{cert}}
if verified {
r.TLS.VerifiedChains = [][]*x509.Certificate{{cert}}
}
return r
}
func TestCertificateIdentity(t *testing.T) {
resetMemoryStore()
defer resetMemoryStore()
iam := NewIdentityAccessManagementWithStore(&S3ApiServerOption{}, nil, "memory")
_, err := iam.loadS3ApiConfigurationFromBytes([]byte(certificateIdentityConfig), true)
require.NoError(t, err)
tests := []struct {
name string
r *http.Request
identity string
errCode s3err.ErrorCode
}{
{"uri SAN", requestWithClientCertificate(clientCertificate("x", "spiffe://example.org/ns/ingest/sa/writer"), true), "ingest-writer", s3err.ErrNone},
{"every field of a match", requestWithClientCertificate(clientCertificate("reporter", "", "other.example", "REPORTER.example.internal"), true), "by-cn", s3err.ErrNone},
{"one field of a match differs", requestWithClientCertificate(clientCertificate("reporter", "", "other.example"), true), "anonymous", s3err.ErrNone},
{"certificate the gateway did not verify", requestWithClientCertificate(clientCertificate("x", "spiffe://example.org/ns/ingest/sa/writer"), false), "anonymous", s3err.ErrNone},
{"plain http", httptest.NewRequest(http.MethodGet, "http://localhost:8333/ingest/object", nil), "anonymous", s3err.ErrNone},
{"disabled identity", requestWithClientCertificate(clientCertificate("retired", ""), true), "", s3err.ErrAccessDenied},
{"two identities", requestWithClientCertificate(clientCertificate("twin", ""), true), "", s3err.ErrAccessDenied},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
identity, errCode := iam.AuthenticateRequest(tc.r)
assert.Equal(t, tc.errCode, errCode)
if tc.identity == "" {
assert.Nil(t, identity)
return
}
require.NotNil(t, identity)
assert.Equal(t, tc.identity, identity.Name)
assert.Equal(t, tc.identity == "anonymous", iam.isAnonymousRequest(tc.r))
})
}
signed := requestWithClientCertificate(clientCertificate("x", "spiffe://example.org/ns/ingest/sa/writer"), true)
signed.Header.Set("Authorization", "AWS4-HMAC-SHA256 Credential=AKIDSIGNER/20260101/us-east-1/s3/aws4_request, SignedHeaders=host, Signature=00")
identity, errCode := iam.AuthenticateRequest(signed)
assert.NotEqual(t, s3err.ErrNone, errCode, "a bad signature is not rescued by the certificate")
assert.Nil(t, identity)
assert.False(t, iam.isAnonymousRequest(signed))
}
func TestCertificateIdentityReadIsNotDeferredAsAnonymous(t *testing.T) {
resetMemoryStore()
defer resetMemoryStore()
iam := NewIdentityAccessManagementWithStore(&S3ApiServerOption{}, nil, "memory")
_, err := iam.loadS3ApiConfigurationFromBytes([]byte(certificateIdentityConfig), true)
require.NoError(t, err)
s3a := &S3ApiServer{iam: iam}
for _, tc := range []struct {
cert *x509.Certificate
deferred bool
}{
{clientCertificate("x", "spiffe://example.org/ns/ingest/sa/writer"), false},
{clientCertificate("retired", ""), false},
{clientCertificate("nobody", ""), true},
} {
r := mux.SetURLVars(requestWithClientCertificate(tc.cert, true), map[string]string{"bucket": "ingest", "object": "object"})
_, deferred := s3a.deferAnonymousObjectRead(r, s3_constants.ACTION_READ, "ingest", "object")
assert.Equal(t, tc.deferred, deferred, tc.cert.Subject.CommonName)
}
}
+70 -7
View File
@@ -2,6 +2,7 @@ package s3api
import (
"context"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
@@ -136,6 +137,7 @@ type Identity struct {
Claims map[string]interface{} // JWT claims for policy substitution
IsStatic bool // Whether identity was loaded from static config (immutable)
IdentityClaim string // Authoritative OIDC identity claim for audit logging (preferred_username/email/sub); empty for non-federated sessions
Certificates []*iam_pb.CertificateMatch
}
// Account represents a system user, a system user can
@@ -889,6 +891,7 @@ func (iam *IdentityAccessManagement) ReplaceS3ApiConfiguration(config *iam_pb.S3
PrincipalArn: generatePrincipalArn(ident.Name),
Disabled: ident.Disabled, // false (default) = enabled, true = disabled
PolicyNames: ident.PolicyNames,
Certificates: ident.Certificates,
}
if ident.Name == AccountAnonymous.Id {
t.Account = &AccountAnonymous
@@ -1108,6 +1111,7 @@ func (iam *IdentityAccessManagement) MergeS3ApiConfiguration(config *iam_pb.S3Ap
PrincipalArn: generatePrincipalArn(ident.Name),
Disabled: ident.Disabled,
PolicyNames: ident.PolicyNames,
Certificates: ident.Certificates,
// File identities are static; set it here so the published identity is
// never briefly observable as non-static (RemoveIdentity guards on it).
IsStatic: fromStaticFile,
@@ -1615,6 +1619,68 @@ func (iam *IdentityAccessManagement) LookupAnonymous() (identity *Identity, foun
return nil, false
}
// authenticateUnsigned names the identity of a request that carries no
// signature or token: the one matching the client certificate the gateway
// verified, else the anonymous identity. It returns no identity when neither
// applies, or when more than one identity matches the certificate.
func (iam *IdentityAccessManagement) authenticateUnsigned(r *http.Request) (*Identity, s3err.ErrorCode, string) {
if identity, matches := iam.lookupByCertificate(r); matches > 0 {
if matches > 1 {
glog.Warningf("client certificate %q matches %d identities", r.TLS.VerifiedChains[0][0].Subject, matches)
return nil, s3err.ErrAccessDenied, "Certificate"
}
if identity.Disabled {
return nil, s3err.ErrAccessDenied, "Certificate"
}
return identity, s3err.ErrNone, "Certificate"
}
if identity, found := iam.LookupAnonymous(); found {
return identity, s3err.ErrNone, "Anonymous"
}
return nil, s3err.ErrAccessDenied, "Anonymous"
}
// isAnonymousRequest reports a request that carries no signature or token and
// whose client certificate names no identity.
func (iam *IdentityAccessManagement) isAnonymousRequest(r *http.Request) bool {
if getRequestAuthType(r) != authTypeAnonymous {
return false
}
_, matches := iam.lookupByCertificate(r)
return matches == 0
}
// lookupByCertificate returns an identity the client certificate the gateway
// verified matches, and how many identities it matches.
func (iam *IdentityAccessManagement) lookupByCertificate(r *http.Request) (match *Identity, matches int) {
if iam == nil || r.TLS == nil || len(r.TLS.VerifiedChains) == 0 || len(r.TLS.VerifiedChains[0]) == 0 {
return nil, 0
}
cert := r.TLS.VerifiedChains[0][0]
iam.m.RLock()
defer iam.m.RUnlock()
for _, identity := range iam.identities {
if slices.ContainsFunc(identity.Certificates, func(m *iam_pb.CertificateMatch) bool { return certificateMatches(m, cert) }) {
match = identity
matches++
}
}
return match, matches
}
func certificateMatches(m *iam_pb.CertificateMatch, cert *x509.Certificate) bool {
if m.GetUriSan() == "" && m.GetDnsSan() == "" && m.GetSubjectCn() == "" {
return false
}
if m.GetUriSan() != "" && !slices.ContainsFunc(cert.URIs, func(u *url.URL) bool { return u.String() == m.GetUriSan() }) {
return false
}
if m.GetDnsSan() != "" && !slices.ContainsFunc(cert.DNSNames, func(name string) bool { return strings.EqualFold(name, m.GetDnsSan()) }) {
return false
}
return m.GetSubjectCn() == "" || cert.Subject.CommonName == m.GetSubjectCn()
}
func (iam *IdentityAccessManagement) lookupByIdentityName(name string) *Identity {
iam.m.RLock()
defer iam.m.RUnlock()
@@ -1854,7 +1920,6 @@ func scrubInternalHeaders(r *http.Request) {
func (iam *IdentityAccessManagement) authenticateRequestInternal(r *http.Request) (*Identity, s3err.ErrorCode, authType) {
var identity *Identity
var s3Err s3err.ErrorCode
var found bool
var amzAuthType string
// Clearing them here — the shared entry point for every auth path —
@@ -1898,10 +1963,9 @@ func (iam *IdentityAccessManagement) authenticateRequestInternal(r *http.Request
amzAuthType = "Jwt"
default:
glog.V(4).Infof("unsigned streaming upload, anonymous request")
amzAuthType = "Anonymous"
if identity, found = iam.LookupAnonymous(); !found {
if identity, s3Err, amzAuthType = iam.authenticateUnsigned(r); identity == nil {
r.Header.Set(s3_constants.AmzAuthType, amzAuthType)
return identity, s3err.ErrAccessDenied, reqAuthType
return identity, s3Err, reqAuthType
}
}
case authTypeJWT:
@@ -1915,10 +1979,9 @@ func (iam *IdentityAccessManagement) authenticateRequestInternal(r *http.Request
return identity, s3err.ErrNotImplemented, reqAuthType
}
case authTypeAnonymous:
amzAuthType = "Anonymous"
if identity, found = iam.LookupAnonymous(); !found {
if identity, s3Err, amzAuthType = iam.authenticateUnsigned(r); identity == nil {
r.Header.Set(s3_constants.AmzAuthType, amzAuthType)
return identity, s3err.ErrAccessDenied, reqAuthType
return identity, s3Err, reqAuthType
}
default:
return identity, s3err.ErrNotImplemented, reqAuthType
+1 -1
View File
@@ -1005,7 +1005,7 @@ func (s3a *S3ApiServer) AuthWithPublicRead(handler http.HandlerFunc, action Acti
return
}
authType := getRequestAuthType(r)
isAnonymous := authType == authTypeAnonymous
isAnonymous := s3a.iam.isAnonymousRequest(r)
glog.V(4).Infof("AuthWithPublicRead: bucket=%s, object=%s, authType=%v, isAnonymous=%v", bucket, object, authType, isAnonymous)
+1 -1
View File
@@ -28,7 +28,7 @@ func isAnonymousObjectRead(r *http.Request) bool {
// their normal authentication path; no-auth development mode is unchanged.
func (s3a *S3ApiServer) deferAnonymousObjectRead(r *http.Request, action Action, bucket, object string) (*http.Request, bool) {
if s3a.iam == nil || !s3a.iam.isEnabled() || action != s3_constants.ACTION_READ ||
getRequestAuthType(r) != authTypeAnonymous || object == "" || object == "/" ||
!s3a.iam.isAnonymousRequest(r) || object == "" || object == "/" ||
(r.Method != http.MethodGet && r.Method != http.MethodHead) || isSOSAPIObject(strings.TrimPrefix(object, "/")) {
return r, false
}