00->1
Learning pathStep 10 of 62Foundations ← All writeups

Identity and Access Management Basics, Explained

If you are reading this, you have probably seen "IAM" on job posts and in cloud documentation, and you already know the difference between authentication and authorization. What you may not know yet is how a company manages the lifetime of thousands of accounts, and why "one login for everything" is both a gift and a risk.

By the end you will be able to describe the account life cycle (define roles, provision, review, remove), explain what single sign-on (SSO) and federation are and name the parts (identity provider, relying party, assertion), tell SAML from OpenID Connect, say why privileged and leftover accounts are the dangerous ones, and run a small account audit yourself.

You should know the basics from Authentication vs. Authorization. For the SQL and Python used in the hands-on section, SQL Basics for Security and Python Basics for Security help, but you can follow the results without them.


1. What identity and access management is

Identity and access management (IAM) is the set of processes and tools that decide who has an account, what that account can do, and when that stops. Authentication proves who is acting. Authorization decides what they may do. IAM is the management layer around both: creating the right accounts, giving the right access, checking it stays right, and removing it in time.

The ISC2 Certified in Cybersecurity exam outline puts this in its own domain, "Identity and Access Management Concepts", with two parts: the identity life cycle ("role definition, provisioning, review, deprovisioning") and logical access control ("least privilege, separation of duties, access control models") (ISC2 CC exam outline). Those two parts are the structure of this post.

An "identity" is not only a person. Accounts also belong to service accounts used by programs (a backup job, an application talking to a database), devices, and shared accounts used by several people. Each one needs an owner, a purpose and an end date, and each one is a way in if forgotten.


2. The identity life cycle

Accounts have a life: they are created, they change, and they should end. Industry shorthand calls the three people-related moments joiner, mover, leaver. That is common vocabulary, not a NIST term. NIST's control catalogue, SP 800-53 Rev. 5, covers the same ground in its account management control (AC-2) and in two personnel controls: PS-4 on termination and PS-5 on transfer.

Stage What happens What NIST SP 800-53 Rev. 5 says
1. Define roles Decide what groups and roles exist and what each one may do, before anyone gets an account AC-2 asks organizations to "define and document the types of accounts allowed and specifically prohibited", to specify "group and role membership" and the "access authorizations (i.e., privileges)" for each account, and to require approvals for requests to create accounts
2. Provision (joiner) Create the account, grant the role, issue the credentials Create, enable, modify, disable and remove accounts "in accordance with" defined policy and procedures (AC-2)
3. Change (mover) A person changes job, so their access should change too PS-5 (Personnel Transfer): "review and confirm ongoing operational need for current logical and physical access authorizations" when people are reassigned, and "modify access authorization as needed"
4. Review Check accounts and their rights regularly AC-2 requires reviewing "accounts for compliance with account management requirements" at a defined frequency. Enhancement AC-6(7) asks to "review ... the privileges assigned to [defined] roles or classes of users to validate the need for such privileges" and to "reassign or remove privileges, if necessary"
5. Remove (leaver) Disable access, revoke credentials, recover items PS-4 (Personnel Termination): "disable system access within [a defined time period]" and "terminate or revoke any authenticators and credentials associated with the individual"

The "defined time period" and "defined frequency" are blanks that each organization fills in; NIST deliberately does not choose one number for everyone.

Other account rules worth knowing

  • Monitor and expire. AC-2 also asks organizations to monitor the use of accounts. Its enhancement AC-2(3) says to disable accounts when they "have expired", "are no longer associated with a user or individual", "are in violation of organizational policy", or "have been inactive for [a defined time period]". NIST adds that disabling such accounts "supports the concepts of least privilege and least functionality which reduce the attack surface of the system".
  • Shared accounts. If shared or group accounts are used, AC-2 requires "a process for changing shared or group account authenticators ... when individuals are removed from the group". Otherwise a leaver still knows the shared password.
  • Tie it to HR. AC-2 also says to "align account management processes with personnel termination and transfer processes". The people who know somebody left are usually not the people who manage the accounts, so the two must be connected.

(NIST SP 800-53 Rev. 5, controls AC-2, AC-6(7), PS-4 and PS-5.)

Why forgotten access matters: a real case

In June 2021 Mandiant's Charles Carmakal told a US House committee hearing about the Colonial Pipeline ransomware incident. The earliest evidence of compromise his team had identified was on 29 April 2021, when the attacker "had logged into a virtual private network (VPN) appliance using a legacy VPN profile and an employee's username and password". He added that "the legacy VPN profile did not require a one-time passcode to be provided" and that it had since been disabled during remediation (prepared statement of Charles Carmakal, House Homeland Security Committee, 9 June 2021).

Be careful what this shows. The statement does not say whose account it was or how the password was obtained. What it does show is a general lesson for IAM: an older access path was still working, protected by one factor, and nobody had turned it off. An inventory of access paths, regular reviews and the removal rule (AC-2(3)) are exactly the controls meant to catch that.


3. Least privilege and privileged accounts

NIST's least privilege control (AC-6) says to "employ the principle of least privilege, allowing only authorized accesses for users (or processes acting on behalf of users) that are necessary to accomplish assigned organizational tasks". It applies to programs as well as people: processes should "operate at privilege levels no higher than necessary".

Three enhancements matter for beginners:

Control In plain words
AC-6(5) Privileged accounts "Restrict privileged accounts on the system to [defined] personnel or roles." Keep the number of administrators small
AC-6(2) Non-privileged access for nonsecurity functions People with powerful accounts should "use non-privileged accounts or roles, when accessing nonsecurity functions". A typical example: an administrator reads email and browses the web with an ordinary account, not the powerful one
AC-6(7) Review of user privileges Periodically re-check privileges and remove those no longer needed

Why do privileged accounts get this attention? One stolen administrator account can change every other account. Privilege Escalation shows what attackers do to reach such accounts, and Security Design Principles covers least privilege and separation of duties as design rules.


4. Single sign-on and federation

A company may use dozens of applications. Making people create and remember a separate password for each is a security problem (people reuse passwords) and a management problem (each leaver needs removing from every app). Single sign-on (SSO) solves the first part. NIST defines it as "an authentication process by which one account and its authenticators are used to access multiple applications ... in a seamless manner, generally implemented with a federation protocol" (NIST SP 800-63-4, via the glossary).

The parts

NIST's federation guideline, SP 800-63C-4 (July 2025), defines the terms. Federation is "the process of authenticating a subscriber to a relying party". The roles:

Role What it does (NIST's words) Also called
Identity provider (IdP) Provides "a bridge between the subscriber account" and the relying party In SAML, the identity provider
Relying party (RP) "Processes assertions from the IdP and provides the service that the subscriber is trying to access" In SAML, the service provider (SP)
Assertion "A verifiable statement about the subscriber account to the RP" The signed message the IdP sends

(NIST SP 800-63C-4.) The same guideline names the benefit and the cost. Federation "allows the subscriber to obtain services from multiple RPs without the need to hold or maintain separate authenticators", but it "also potentially gives the IdP broad visibility into a subscriber's activities and status".

How a typical sign-in works

 You          App (relying party)             Identity provider (IdP)
  |  open app          |                                 |
  |------------------->|                                 |
  |  "log in via IdP"  |                                 |
  |<-------------------|                                 |
  |  sign in here (password + MFA)                       |
  |----------------------------------------------------->|
  |                    |   signed assertion / ID token   |
  |<-----------------------------------------------------|
  |  hand it to the app|                                 |
  |------------------->|  app checks signature, issuer,  |
  |                    |  audience, expiry               |
  |  you are in        |                                 |
  |<-------------------|                                 |

You prove who you are once, to the IdP. The app never sees your password; it sees a signed statement from the IdP.

SAML and OpenID Connect

Two protocols carry that statement.

SAML 2.0 OpenID Connect (OIDC)
What it is A framework for exchanging security information between parties, from the OASIS standards group. The overview calls multi-domain web single sign-on "arguably the most important use case for which SAML is applied" "A simple identity layer on top of the OAuth 2.0 protocol"
The message A SAML assertion: "statements about a principal that an asserting party claims to be true", defined by an XML schema An ID Token, "represented as a JSON Web Token (JWT)"
Roles Identity provider and service provider OpenID Provider and Relying Party (the client)

(OASIS SAML 2.0 Technical Overview, OpenID Connect Core 1.0.) Authentication vs. Authorization explains why OIDC, not bare OAuth, is the right choice for login.

What the app must check

Receiving a token is not the same as trusting it. The OpenID Connect specification lists what a client must validate in an ID Token, including:

  • the issuer (iss) must match the provider you expect;
  • the audience (aud) must contain the application's own client ID, or the token must be rejected;
  • the signature must be valid, using the keys provided by the issuer;
  • the current time must be before the expiry (exp).

(OpenID Connect Core 1.0, section 3.1.3.7.) Section 7 below lets you try this.

Risks of SSO

Risk What to do
One account opens many doors Protect the IdP account with strong, phishing-resistant MFA (see Authentication vs. Authorization and Phishing)
The IdP sees a lot NIST notes the visibility. Choose the IdP deliberately and protect its logs
Compromised IdP means compromised apps Monitor sign-ins, and treat the IdP as one of your most critical systems
SSO is only authentication Each app must still decide what the person may do (authorization)
Leavers must be removed everywhere Disabling the IdP account helps, but apps that keep their own local accounts or long-lived sessions need attention too

Provisioning at scale: SCIM

Creating and removing accounts by hand in every app does not scale. SCIM, the System for Cross-domain Identity Management, is an IETF standard for that. RFC 7644 describes it as "an HTTP-based protocol that makes managing identities in multi-domain scenarios easier to support via a standardized service", with the intent "to reduce the cost and complexity of user management operations" (RFC 7644, RFC 7643 for the schema). In practice, when an identity system supports it, creating or disabling a person in one place can create or disable them in connected apps, which supports the joiner and leaver stages above.


5. Putting it together

Question IAM answer
Who gets an account? Approved requests, tied to an owner, following defined roles
What can it do? The role's rights only (least privilege)
How do they sign in? Preferably through an identity provider with strong MFA
How do we notice drift? Regular reviews and automated checks for inactive, ownerless and shared accounts
What happens when someone leaves or moves? Access is changed or removed on a defined timetable
What about programs? Service accounts have owners, narrow rights and no human logins

6. Practise: audit a set of accounts

This exercise uses SQLite, as in SQL Basics for Security. The data is invented. Save it as accounts.sql:

CREATE TABLE accounts (
  username     TEXT PRIMARY KEY,
  owner_status TEXT,              -- from HR: 'active' or 'terminated'; NULL = no human owner on record
  role         TEXT NOT NULL,
  enabled      INTEGER NOT NULL,  -- 1 = can sign in, 0 = disabled
  last_login   TEXT NOT NULL,
  shared       INTEGER NOT NULL   -- 1 = used by more than one person
);

INSERT INTO accounts VALUES
  ('alice',      'active',     'staff', 1, '2026-11-04', 0),
  ('bob',        'active',     'staff', 1, '2026-11-03', 0),
  ('carol',      'active',     'admin', 1, '2026-11-05', 0),
  ('dave',       'terminated', 'staff', 1, '2026-09-30', 0),
  ('erin',       'active',     'admin', 1, '2026-02-14', 0),
  ('frank',      'terminated', 'admin', 0, '2026-08-01', 0),
  ('helpdesk',   'active',     'staff', 1, '2026-11-05', 1),
  ('svc-backup', NULL,         'admin', 1, '2026-11-05', 0);
sqlite3 audit.db < accounts.sql
sqlite3 -header -column audit.db

For repeatable results the queries use a fixed "today" of 2026-11-05. In real use you would use the current date.

Check 1: leavers whose accounts still work.

SELECT username, role, last_login FROM accounts
WHERE owner_status = 'terminated' AND enabled = 1;
username  role   last_login
--------  -----  ----------
dave      staff  2026-09-30

dave left but can still sign in. frank also left, but his account is correctly disabled (enabled = 0). This is the leaver rule (PS-4) failing for one account.

Check 2: enabled accounts idle for more than 90 days.

SELECT username, role, last_login FROM accounts
WHERE enabled = 1 AND julianday('2026-11-05') - julianday(last_login) > 90;
username  role   last_login
--------  -----  ----------
erin      admin  2026-02-14

erin is an administrator who has not signed in for months. Inactive accounts are a target and, under AC-2(3), a candidate for disabling. (The 90 is only an example. Organizations choose their own number.)

Check 3: accounts with no human owner.

SELECT username, role FROM accounts
WHERE enabled = 1 AND owner_status IS NULL;
 username   role
----------  -----
svc-backup  admin

A service account with administrator rights and no named owner is a risk: nobody is responsible for reviewing it.

Check 4: shared accounts.

SELECT username, owner_status FROM accounts
WHERE enabled = 1 AND shared = 1;
username  owner_status
--------  ------------
helpdesk  active

If anyone leaves the help desk, the password for helpdesk has to change (AC-2). Shared accounts also make it hard to say who did what.

Check 5: a trap with NULL. Someone writes "list accounts whose owner is not active":

SELECT username FROM accounts WHERE owner_status <> 'active';
username
--------
dave
frank

It misses svc-backup! Comparing a missing value (NULL) with <> is never true, so the row with no owner silently disappears. Write owner_status IS NULL OR owner_status <> 'active' instead. This is the same NULL behaviour from the SQL post, and it shows how an audit query can hide exactly the accounts you most need to see.

Check 6: risky admin accounts, all at once.

SELECT username FROM accounts
WHERE enabled = 1 AND role = 'admin'
  AND (owner_status = 'terminated'
       OR owner_status IS NULL
       OR julianday('2026-11-05') - julianday(last_login) > 90
       OR shared = 1);
username
----------
erin
svc-backup

Two of the three enabled administrators (erin and svc-backup) need a conversation with their owners. Only carol is clean.

(Whether to disable an account straight away or investigate first is a judgement call for the system owner. These queries find candidates; they do not make the decision.)


7. Practise: look inside a token

An OpenID Connect ID Token is a JSON Web Token: three parts, separated by dots. The first two are Base64-encoded JSON, not encrypted, which Cryptography Basics explains is only an encoding. The third part is the signature. This script builds a made-up token, decodes it, and then validates it the way the specification asks. It uses a shared secret (HMAC, algorithm HS256) so that everything is in one file. Real OpenID providers normally sign with RS256, the specification's default, using a private key, and the app checks the signature with the provider's public key.

Save as jwt_demo.py:

import base64, hashlib, hmac, json

def b64url(data):
    return base64.urlsafe_b64encode(data).rstrip(b"=").decode()

def b64url_decode(text):
    return base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))

secret = b"lab-only-secret"           # a made-up key for this experiment

def make_token(payload):
    header = {"alg": "HS256", "typ": "JWT"}
    signing_input = b64url(json.dumps(header).encode()) + "." + b64url(json.dumps(payload).encode())
    sig = hmac.new(secret, signing_input.encode(), hashlib.sha256).digest()
    return signing_input + "." + b64url(sig)

def verify(token, expected_aud, now):
    signing_input, sig = token.rsplit(".", 1)
    good = hmac.new(secret, signing_input.encode(), hashlib.sha256).digest()
    if not hmac.compare_digest(b64url(good), sig):
        return "REJECT: bad signature"
    claims = json.loads(b64url_decode(signing_input.split(".")[1]))
    if claims["aud"] != expected_aud:
        return "REJECT: wrong audience"
    if now >= claims["exp"]:
        return "REJECT: expired"
    return "ACCEPT: " + claims["sub"]

now = 1_800_000_000
token = make_token({"iss": "https://idp.example", "sub": "alice", "aud": "app-123",
                    "iat": now - 60, "exp": now + 300})
print(token)
print()
header_b64, payload_b64, _ = token.split(".")
print(json.loads(b64url_decode(header_b64)))
print(json.loads(b64url_decode(payload_b64)))
print()
print(verify(token, "app-123", now))
print(verify(token, "other-app", now))
print(verify(token, "app-123", now + 301))

# An attacker edits the payload (alice -> carol) but cannot re-sign it
forged_payload = {"iss": "https://idp.example", "sub": "carol", "aud": "app-123",
                  "iat": now - 60, "exp": now + 300}
h, _, s = token.split(".")
forged = h + "." + b64url(json.dumps(forged_payload).encode()) + "." + s
print(verify(forged, "app-123", now))

Run python3 jwt_demo.py:

eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJpc3MiOiAiaHR0cHM6Ly9pZHAuZXhhbXBsZSIsICJzdWIiOiAiYWxpY2UiLCAiYXVkIjogImFwcC0xMjMiLCAiaWF0IjogMTc5OTk5OTk0MCwgImV4cCI6IDE4MDAwMDAzMDB9.4WaFze_kMoRt3FhRahV59CHMaPkfxGxfdSEHTXDqUZA

{'alg': 'HS256', 'typ': 'JWT'}
{'iss': 'https://idp.example', 'sub': 'alice', 'aud': 'app-123', 'iat': 1799999940, 'exp': 1800000300}

ACCEPT: alice
REJECT: wrong audience
REJECT: expired
REJECT: bad signature

What you just saw:

  1. Anyone can read a token. Splitting on the dots and decoding showed iss, sub, aud, iat and exp with no key at all. Never put secrets in one.
  2. Reading is not trusting. The same token was accepted, then rejected for the wrong audience and for being expired. These are the checks the OpenID Connect specification requires.
  3. A forged edit fails. Changing alice to carol broke the signature, because only the holder of the key can produce a matching one.

(This is a teaching sketch, not production code. Real applications should use a well-maintained library for token validation, which also handles the many details this script leaves out.)


8. Common mistakes

Mistake The facts
"We turn on access when someone joins; removal can wait" Leavers and movers are where stale access builds up. NIST PS-4 and PS-5 set rules for both
"A disabled employee means a disabled account" Only if somebody disables it, in every system, including local, shared and legacy accounts
"Everyone in IT should be an administrator" Restrict privileged accounts (AC-6(5)) and use ordinary accounts for ordinary work (AC-6(2))
"Service accounts don't need owners" Ownerless accounts are never reviewed. Name an owner, a purpose and an expiry
"Shared logins are fine for a small team" Nobody is accountable, and leavers still know the password. Change it when people leave, or avoid shared accounts
"SSO makes us secure" It reduces password sprawl, but concentrates risk in the IdP. Protect it with phishing-resistant MFA
"SSO also handles permissions" It proves who you are. Each application still decides what you may do
"A signed-in token is a trusted token" The app must validate the issuer, audience, signature and expiry
"Tokens are encrypted, so I can put data in them" A JWT's first two parts are only encoded. Anyone can read them
"Once access is set up, it's done" Reviews are part of the life cycle. People change jobs and systems change
"Audit queries are objective" A query only finds what it is written to find. Watch for NULL and for accounts missing from the data you check

Closing

IAM is the discipline of keeping accounts and access in line with reality. Accounts are born, they change and they must end. Most breaches that involve identity do not break a clever lock; they walk through a door nobody remembered to close or never knew existed.

Keep these points:

  • Life cycle: define roles, provision, review, and remove. Treat movers and leavers as seriously as joiners.
  • Least privilege, with few privileged accounts and ordinary accounts for everyday work.
  • Shared and service accounts need owners, limited rights and a plan for when people leave.
  • SSO and federation: the identity provider authenticates once and vouches to relying parties with an assertion. Read the benefit and the risk together.
  • SAML and OpenID Connect both carry that statement; the app must validate issuer, audience, signature and expiry.
  • SCIM and HR links help automate provisioning and removal.
  • Audit regularly, and beware of NULL and hidden accounts.

If you can look at a list of accounts and spot the leaver who can still sign in, the idle administrator and the service account nobody owns, you understand the foundation.

Related: Authentication vs. Authorization explains the two halves IAM manages, Security Design Principles covers least privilege and separation of duties, and Security Operations shows how monitoring picks up the signs when an account is misused.