SQL Server Authentication
You set up sql server authentication to check who can enter a database instance. It verifies an account with a login or a contained user password before running queries. Teams use this process to give developers, apps, and AI agents safe database access. Understanding logins, users, and roles helps you keep tight control over every query. How sql server authentication works in practice In SQL Server, a login lets you enter the main server instance. That login lives in the master database and
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up sql server authentication to check who can enter a database instance. It verifies an account with a login or a contained user password before running queries.
Teams use this process to give developers, apps, and AI agents safe database access. Understanding logins, users, and roles helps you keep tight control over every query.
How sql server authentication works in practice
In SQL Server, a login lets you enter the main server instance. That login lives in the master database and works across many databases on that server. Once inside, the login maps to a database user inside each target database. A database user is the identity of that login when it connects to a database. SQL Server supports thirteen distinct types of database users for different access needs.
Sometimes a person or an AI agent only needs one or a few databases. In that case, an admin can use a contained database user with a password. A contained user lives right inside the target database instead of the master database. An admin must turn on contained databases on the server and database first.
After a user logs in, fixed database roles decide what that user can do. You cannot change the built-in permissions assigned to these fixed database roles. Every role, including the basic public role, gives the user permission to connect. The data reader role lets members read all data from all user tables and views. The data writer role lets members add, delete, or change data in user tables. The database owner role can run all setup tasks and even drop the database.
Admins also use deny roles to block actions across a database. The deny data reader role stops a user from reading user tables, views, or metadata. The deny data writer role blocks a user from adding, changing, or deleting table data.
K8s API Server Authentication + SQL Query Filtering: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Security tradeoffs of static logins and fixed roles
Static SQL logins and fixed roles solve basic access needs, but they leave gaps. Sharing a single password among developers or scripts makes auditing hard. If a password leaks, anyone with that secret can log in from an allowed network. Rotating static keys across many apps and developer laptops takes hours of manual work.
Fixed roles also apply broad rules across an entire database. A member of the data reader role can read every user table and view. That includes sensitive columns like emails, phone numbers, card numbers, and national IDs. Standard roles do not rewrite matched fields in query results on the fly.
Teams also lack query-level controls when an active session begins. A user with write access can run a bad delete query without a peer check. AI agents with read roles can pull whole tables of private user data at once. Adding a proxy layer lets teams link logins to identity providers and mask sensitive fields. It also lets teams require peer approval before risky commands run against production tables.
Govern SQL Server queries and responses in flight
Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.
With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.
Frequently asked questions
What is the difference between a login and a database user?
A login sits in the master database and gives access to the server instance. A database user is the identity of that login inside one specific database. You use a login in master when someone needs many databases on one instance.
When should I use a contained database user?
Use a contained database user when someone needs access to one or a few databases. This user has its own password and does not need a login in master. An admin must enable contained databases on the server and the database first.
How do I give a user read-only access in SQL Server?
Add the database user to the fixed data reader role to allow reading all tables. Make sure the user is not in the data writer or database owner roles. You can also add the user to the deny data writer role to block changes.
Related guides
In this post