Home / Companies / Clerk / Blog / August 2024

August 2024 Summaries

6 posts from Clerk

Filter
Month: Year:
Post Summaries Back to Blog
Clerk offers two primary methods for interacting with user data: the Backend API and Webhooks, each suited for different scenarios. The Backend API is designed for direct querying and manipulating user data, providing a straightforward request-response model ideal for synchronous operations, but it is subject to rate limits, which can restrict its use in high-demand applications. It allows efficient data retrieval via batching with functions like getUser and getUserList, making it suitable for obtaining the latest information directly from Clerk. In contrast, Webhooks are event-driven and enable automatic data synchronization across systems by sending event notifications to specified endpoints without rate limitations, making them ideal for updating external platforms or databases. However, Webhooks require handling asynchronous events, verifying request sources, and managing potential duplicates, adding complexity compared to the Backend API. Despite these challenges, Webhooks are advantageous for applications needing real-time updates and scalability, such as notifying systems of user changes or integrating with external services.
Aug 29, 2024 1,541 words in the original blog post.
Schema migrations are essential for safely updating the schema of a relational database, as they allow changes to be applied in a controlled manner without disrupting existing data, in contrast to stateless application code deployments. The process involves using SQL scripts stored in version control to track schema changes over time, which can be applied sequentially to recreate a database's state at any point. A practical example using Drizzle, a type-safe ORM for TypeScript applications, illustrates how to generate and apply schema migrations, including adding a new column to a table in a Postgres database hosted by Neon. By simulating different environments, such as development and production, the article demonstrates how schema migrations keep database schemas synchronized with application code changes. Additionally, automating these migrations with GitHub Actions ensures consistency and reduces the risk of errors during deployment, as it integrates with platforms like Vercel to trigger migrations and deployments simultaneously when changes occur in the main repository branch.
Aug 22, 2024 1,416 words in the original blog post.
The text provides a detailed guide on accessing authenticated user data using Clerk, highlighting methods suitable for different runtime environments and application needs. It emphasizes the use of Clerk's Frontend API with the `useUser()` hook for client-side operations, which is ideal for dynamically updating the UI based on user data without exceeding rate limits. For server-side tasks, the `currentUser()` function from Clerk's Backend API is recommended, though it is subject to rate limits of 100 requests per 10 seconds. Additionally, session claims offer a way to efficiently access user information without API calls, though they have size limitations due to browser cookie constraints. The guide advises against storing large or private user data in session tokens and suggests leveraging custom session claims for frequent backend access to avoid API call limitations, while also noting the importance of choosing the right method based on the specific use case and environment.
Aug 15, 2024 1,353 words in the original blog post.
Managing permissions in large SaaS applications can be challenging, but Clerk simplifies this by providing role-based access control (RBAC) through its Organizations feature, which is crucial for B2B applications. RBAC involves assigning permissions to users based on their roles, which are often aligned with job functions, allowing users access to only what they need. In Clerk, developers can create custom roles and permissions, enhancing flexibility and security management. The example given is a team-based task management app built with Next.js, where roles like Viewer, Member, and Manager determine users' abilities to view, edit, or manage tasks. Clerk offers authorization helper functions to verify user permissions, and the sessionClaims object provides access to organizational permissions, ensuring that application functionality aligns with user roles. This approach facilitates efficient security management by adjusting application behavior based on user roles, making RBAC easily accessible for applications of any size.
Aug 09, 2024 1,362 words in the original blog post.
Security researchers at Salt uncovered an OAuth vulnerability that can be combined with any XSS vulnerability to facilitate account takeovers. Clerk, a company involved in OAuth implementations, swiftly addressed the issue upon discovery, noting that their default configuration already protected over 99.7% of their customers. They released an update to safeguard the remaining users. The vulnerability, termed "Open Response Type," involves manipulating OAuth's response_type parameter to extract unused secret codes from URLs, potentially bypassing HttpOnly protections even after XSS vulnerabilities are patched. Clerk mitigated this by processing OAuth codes on separate origins to prevent XSS exploits and by removing unexpected URL fragments to stop malicious actors from gaining unauthorized access.
Aug 07, 2024 1,370 words in the original blog post.
The article details a method for implementing a per-user monetization model in a web application using Clerk Organizations and Stripe, with a focus on B2B software. It explains how businesses can create organizations and invite users, manage licenses, and handle subscriptions through an open-source application called Team Task. The process involves creating organizations with Clerk, purchasing licenses via Stripe, and managing them using a database to track license counts. Stripe's webhooks facilitate the automation of customer creation, license purchases, and subscription management, allowing users to independently manage their licenses and subscriptions through a Stripe-hosted Customer Portal. The article emphasizes self-service capabilities, enabling users to perform actions without developer assistance, and includes detailed code explanations for integrating these services to achieve a scalable, automated monetization workflow.
Aug 02, 2024 2,383 words in the original blog post.