MediumUnderstanding SSO, Authentication, Authorization, RBAC, and Audit Trails Through a Real-World Cognito + Snowflake Integration | by Safnas | Medium
Sitemap
Safnas

Safnas

Data Engineer | AI Engineer | Data Analysis | Business Intelligence | Full Stack Developer

Understanding SSO, Authentication, Authorization, RBAC, and Audit Trails Through a Real-World Cognito + Snowflake Integration

6 min readJun 24, 2026

--

Introduction

Modern software systems rarely operate in isolation. Most enterprise applications today are composed of multiple services that need to trust each other in a secure and consistent way. This is where concepts like Single Sign-On (SSO), authentication, authorization, RBAC, and audit trails become essential.

At first glance, these terms often feel overlapping or abstract. However, when understood through a real-world system, their boundaries become much clearer.

In this article, I’ll break down these concepts in a practical way and connect them to an actual implementation involving AWS Cognito, Snowflake, and a custom application dashboard.

What SSO Actually Means

Single Sign-On (SSO) is a mechanism that allows a user to authenticate once and gain access to multiple systems without logging in again.

In traditional systems, each application maintains its own login flow. This leads to repeated authentication, fragmented sessions, and poor user experience.

SSO solves this by introducing a central identity provider.

In simple terms:

SSO means the user proves their identity once, and every connected system trusts that proof.

A common everyday example is Google’s ecosystem. When you log into Gmail, you are automatically authenticated across YouTube, Drive, and other Google services without signing in again.

Press enter or click to view image in full size
Overview of SSO

Authentication vs Authorization

One of the most important distinctions in identity systems is understanding the difference between authentication and authorization.

Authentication is the process of verifying identity. It answers the question, "Who are you?”

This typically involves login credentials such as a username and password, or a federated login through providers like AWS Cognito, Google, or Microsoft.

Once authentication succeeds, the system issues a token representing the user’s identity.

Authorization, on the other hand, determines what that user is allowed to do. It answers: “What permissions do you have?”

Even if the system knows who you are, it does not automatically mean you can access everything.

A simple analogy is entering a building. Authentication is showing your ID at the entrance. Authorization is whether you are allowed into specific rooms inside the building.

Press enter or click to view image in full size

In most modern systems:

  • Cognito handles authentication
  • Database handles authorization

Understanding Tokens in Modern Systems

When a user logs in successfully, identity providers do not keep the session alive on the server side in a traditional way. Instead, they issue a token, typically a JSON Web Token (JWT).

A JWT is a self-contained object that carries information about the user, such as identity, expiration time, and sometimes custom attributes.

Once issued, the token does not change. This immutability is a core design principle of modern identity systems.

This also means that any change in user attributes (such as roles) will not be reflected until a new token is issued.

This behavior becomes very important when designing authorization systems.

What RBAC Means in Practice

Role-Based Access Control (RBAC) is a method of managing permissions using roles instead of assigning permissions directly to users.

Instead of defining permissions per user, systems define roles such as:

  • Admin
  • Analyst
  • Viewer

Each role carries a set of permissions, and users are assigned to roles.

This makes large-scale systems significantly easier to manage.

For example, instead of updating 100 users individually, you only update the role definition once.

Snowflake is heavily built around RBAC. Every action inside Snowflake is governed by roles, and access is granted based on role hierarchy.

Audit Trails and Why They Matter

An audit trail is a record of everything that happens inside a system. It provides visibility into user actions, system changes, and access patterns.

Get Safnas’s stories in your inbox

Join Medium for free to get updates from this writer.

In data platforms like Snowflake, audit trails are critical for:

  • Security monitoring
  • Compliance requirements
  • Debugging unexpected behavior
  • Tracking sensitive data access

A typical audit log records:

  • Who performed an action
  • When it was performed
  • What data was accessed
  • Which role was used
Press enter or click to view image in full size

Real-World Implementation: Cognito + Snowflake SSO

Now let’s connect these concepts to a real implementation.

The system consisted of three main components:

  • A custom application dashboard
  • AWS Cognito as the identity provider
  • Snowflake as the data warehouse

The goal was to enable users to log in once and execute queries on Snowflake through the application securely.

Authentication Flow

When a user logs into the application, AWS Cognito handles authentication. After successful login, Cognito issues an ID token that represents the user.

This token contains identity information such as name, email, and unique user identifiers. It can also contain custom claims, which play an important role in authorization.

The application then uses this token to initiate a session with Snowflake through a connection pooling mechanism.

The Key Challenge

During implementation, everything worked correctly on the authentication side. Users were successfully logging in, and tokens were being generated as expected.

However, Snowflake consistently rejected the token with an “Invalid Token” error.

At first, the assumption was that role handling could be managed externally at the application layer. Since Cognito roles can change over time, it seemed reasonable to avoid embedding role information directly inside the token to prevent stale authorization states.

The idea was to pass role information dynamically during Snowflake connection and let Snowflake handle enforcement independently.

However, this design did not work as expected.

Root Cause

After extensive investigation through documentation and system behavior analysis, the root cause became clear.

Snowflake requires that authorization context must be included inside the signed identity token itself. External role injection during session creation is not considered trustworthy because it is not part of the signed identity assertion.

This is a fundamental principle of secure distributed systems: the identity provider is the only trusted source of both identity and authorization context.

Final Solution

The final implementation involved updating the Cognito configuration to include a custom role claim inside the ID token.

This allowed roles to be dynamically assigned in Cognito while still being securely embedded within the token itself.

Snowflake could then extract the role from the token and apply its internal RBAC system accordingly.

This resolved the authentication issue and enabled a fully functional end-to-end SSO flow.

Press enter or click to view image in full size

Key Learnings

This implementation reinforced several important principles in identity and access management systems.

Authentication and authorization are separate concepts, but authorization must still be anchored in a trusted identity assertion.

Tokens are immutable, meaning system design must account for delayed propagation of changes such as role updates.

RBAC remains the most scalable approach for managing permissions in enterprise systems.

Finally, auditability is not optional in data systems; it is a core requirement for trust, compliance, and operational visibility.

Conclusion

SSO systems are not just about simplifying login flows. They are about establishing trust boundaries between systems and ensuring that identity and authorization are consistently enforced across distributed components.

In this implementation, the key realization was that Snowflake does not trust externally injected roles. It only trusts what is embedded within a signed token issued by the identity provider.

Once this principle was understood, the system naturally aligned into a secure and scalable architecture.

Understanding these concepts is essential for building modern cloud-native systems that involve identity, security, and data access at scale.

--

--

Safnas
Safnas

Data Engineer | AI Engineer | Data Analysis | Business Intelligence | Full Stack Developer