Skip to content

feat(api-bundle): add Bearer token authentication support for Storage API#462

Merged
ondrajodas merged 6 commits intomainfrom
ondra/AJDA-2163
Jan 28, 2026
Merged

feat(api-bundle): add Bearer token authentication support for Storage API#462
ondrajodas merged 6 commits intomainfrom
ondra/AJDA-2163

Conversation

@ondrajodas
Copy link
Copy Markdown
Contributor

@ondrajodas ondrajodas commented Jan 23, 2026

Summary

  • Add support for authenticating Storage API requests using Authorization: Bearer header as an alternative to X-StorageApi-Token
  • Extend TokenAuthenticatorInterface with getAuthorizationHeader() method to allow authenticators to specify Authorization header support
  • Update AttributeAuthenticator to check both primary header and Authorization header, preventing simultaneous use of both

Changes

  • TokenAuthenticatorInterface: Added getAuthorizationHeader() method
  • StorageApiTokenAuthenticator: Implements Authorization header support, returns "Authorization"
  • ManageApiTokenAuthenticator: Explicitly rejects Authorization header usage by throwing exception
  • AttributeAuthenticator: Enhanced to handle both authentication methods with proper validation
  • composer.json: Moved storage-api-php-client-branch-wrapper from require-dev to require for Bearer token support
  • Tests: Comprehensive test coverage for all authentication scenarios

🤖 Generated with Claude Code

@linear
Copy link
Copy Markdown

linear Bot commented Jan 23, 2026

continue;
}

// Get token from primary header or Authorization header
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Já jsem si původně představoval, že to bude jinej authenticator, jenže to by se pak musel přidat do všech controlerů a to by bylo omrd a nic by to nepřineslo, takže to je vlastně takhle dobrý - akorát se mě moc nelibí, že je to takhle v tom Authenticatoru - co na to jít spíš takhle #463 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, dobrý nápad 👍 udělal jsem to tak

@ondrajodas ondrajodas requested a review from odinuv January 27, 2026 15:46
Copy link
Copy Markdown
Member

@odinuv odinuv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dobrý, tak ještě prosím to pořadí ať je konzistentní

return $token;
}

// Check Authorization header
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self::assertSame('some-token-without-bearer', $authenticator->extractToken($request));
}

public function testExtractTokenPrefersStorageApiTokenHeader(): void
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ondrajodas ondrajodas requested a review from odinuv January 27, 2026 20:52
…nticators

Simplify TokenAuthenticatorInterface by replacing getTokenHeader() and
getAuthorizationHeader() with a single extractToken(Request) method.
Each authenticator now handles its own token extraction logic, making
the code cleaner and more flexible.
@ondrajodas ondrajodas merged commit 10afb46 into main Jan 28, 2026
6 checks passed
@ondrajodas ondrajodas deleted the ondra/AJDA-2163 branch January 28, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants