A Rails API authentication gem using JSON Web Tokens (JWT) for seamless token-based authentication.
Knock is a Ruby gem that provides JWT-based authentication for Rails API-only applications. It offers a straightforward way to secure API endpoints and manage user sessions without server-side sessions, using stateless tokens.
Rails developers building API-only applications who need a simple, convention-over-configuration approach to JWT authentication. It's particularly suited for those using Rails' built-in authentication mechanisms like has_secure_password.
Developers choose Knock for its seamless Rails integration via the Knock::Authenticable module, minimal configuration, and flexibility with custom user models and token payloads. It simplifies JWT implementation compared to using the jwt gem directly, with built-in test helpers and support for multiple entities.
Seamless JWT authentication for Rails API
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Integrates easily via the Knock::Authenticable module in controllers, allowing authentication with minimal code like a before_action call.
Works with any user model implementing an authenticate method, such as Rails' has_secure_password, making it adaptable to existing setups.
Allows overriding to_token_payload in the user model to include custom data in JWT tokens, providing extensibility for specific needs.
Includes utilities for creating authenticated requests in tests, simplifying test setup for secured endpoints as shown in the README.
The author explicitly states it's not maintained and recommends using the jwt gem directly, posing risks for security vulnerabilities and compatibility with newer Rails versions.
Focuses only on basic JWT issuance and validation, lacking built-in support for refresh tokens, token revocation, or integration with external auth providers like OAuth.
Designed specifically for Rails API applications, so it's unsuitable for traditional web apps with server-side sessions or projects using other frameworks without significant adaptation.