Identity and access management
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
Every request to a cloud service is checked twice: who is asking (authentication), and are they allowed to do this (authorization)? Follow one person, Alice, as she signs in with multi-factor authentication and sends three requests to cloud storage. Her JSON policy allows one, an explicit Deny blocks the second, and the third is denied by default. Then see why least privilege matters and how programs use roles with temporary credentials instead of passwords.
Who, and what may they do?
In the cloud, every request, such as "read this file", is checked. Identity and access management (IAM) asks two questions: who is asking (authentication), and are they allowed to do this (authorization)?
every request to a cloud service is checked 1. authentication who is asking? 2. authorization may they do this, to that? IAM = identity and access management
اقرأ الدرس خطوة بخطوة
Who, and what may they do?
In the cloud, every request, such as "read this file", is checked. Identity and access management (IAM) asks two questions: who is asking (authentication), and are they allowed to do this (authorization)?
every request to a cloud service is checked 1. authentication who is asking? 2. authorization may they do this, to that? IAM = identity and access managementIdentities
An identity that can send requests is called a principal. It can be a person or a program. Alice is an IAM user: an identity for one person. The app server is a program; we give it an identity at the end.
principal = who or what sends a request Alice an IAM user (one person) app server a program (a role, step 10) no identity, no accessProve who you are
Alice signs in with her password plus a one-time code from her phone. Using two kinds of proof is multi-factor authentication (MFA). She gets credentials that prove who she is. Nobody has said yet what she may do.
authentication: who is asking? something she knows password something she has phone code (MFA) → credentials: later requests are signed with them still unknown: what she is allowed to doPermissions are written down
What Alice may do is written in a policy: a JSON document attached to her. Each statement has an Effect (Allow or Deny), an Action (what can be done) and a Resource (to what). Hers has two statements.
a policy = a list of statements Effect Allow or Deny Action s3:GetObject = read a file s3:DeleteObject = delete a file Resource arn:aws:s3:::photos/* = anything in the photos bucket "*" = anything at allRequest 1: allowed
Alice asks to read photos/cat.jpg (the action s3:GetObject). Her credentials pass the "who?" check. Then her policy is checked: statement 1 allows reading anything in photos and nothing denies it, so she gets the file.
request s3:GetObject photos/cat.jpg who? Alice ✓ Deny? statement 2: DeleteObject ≠ GetObject Allow? statement 1: matches ✓ → ALLOW (explicit allow)Request 2: explicit deny
Next she tries to delete the same photo (s3:DeleteObject). Statement 2 denies that action on every resource ("*"). An explicit Deny always wins, even over an Allow, so the request is refused and nothing is deleted.
request s3:DeleteObject photos/cat.jpg who? Alice ✓ Deny? statement 2: matches ✗ → DENY (explicit deny) a Deny beats any AllowRequest 3: denied by default
Then she asks to read payroll/pay.csv (s3:GetObject). No statement allows reading the payroll bucket. In IAM everything starts denied: unless a policy allows an action, the answer is no. This is called an implicit deny.
request s3:GetObject payroll/pay.csv who? Alice ✓ Deny? no statement matches Allow? photos/* does not match payroll/… → DENY (implicit deny: the default)The rule, in order
The check follows one rule. First, if any statement denies the request, deny. Otherwise, if a statement allows it, allow. Otherwise, deny. A tiny Python version of that rule gives the same three answers.
from fnmatch import fnmatchcase as match def allowed(policy, action, resource): hits = [s["Effect"] for s in policy["Statement"] if match(action, s["Action"]) and match(resource, s["Resource"])] if "Deny" in hits: return False # 1. explicit deny wins return "Allow" in hits # 2. allow, else 3. deny allowed(policy, "s3:GetObject", "…photos/cat.jpg") # True allowed(policy, "s3:DeleteObject", "…photos/cat.jpg") # False allowed(policy, "s3:GetObject", "…payroll/pay.csv") # FalseLeast privilege
Alice can read photos, but cannot delete them or open payroll. Giving each identity only the permissions its job needs, and nothing more, is called least privilege. If her password ever leaks, the damage stays small.
least privilege: only what the job needs photos read ✓ photos delete ✗ payroll read ✗ start from nothing, add what is neededRoles for programs
The app server must read photos too, but a password stored on a server can be stolen. Instead it uses a role: an identity with a policy but no password. AWS gives it temporary credentials that expire and are renewed automatically.
role = an identity with permissions, no password app server takes on the role → temporary credentials (they expire) AssumeRole default: 3600 s = 1 hour on a server: renewed automatically request s3:GetObject photos/… → ALLOWSame idea in every cloud
Google Cloud and Microsoft Azure use other names: roles are granted to principals in an allow policy, or by a role assignment. The idea is the same everywhere: prove who you are, then check what you are allowed to do.
who what they may do AWS IAM user/role policy statements Google principal role in an allow policy Azure principal role assignment (RBAC) 1. authenticate 2. authorize every request
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01Alice types her password and a code from her phone. Which question does that answer?
Signing in proves who she is: that is authentication. Using two kinds of proof (password plus phone code) is multi-factor authentication. What she may do is decided separately, by her policies.
02A policy allows s3:GetObject on photos/*. Another statement denies s3:DeleteObject on "*". Alice tries to delete photos/cat.jpg. What happens?
The Deny statement matches the action s3:DeleteObject on every resource. In IAM an explicit Deny overrides any Allow.
03No statement in Alice's policy allows reading the payroll bucket. Can she read payroll/pay.csv?
IAM denies every request by default. A request goes through only if some policy allows it and nothing explicitly denies it.
04What does least privilege mean?
With only the permissions it needs, a leaked password or a buggy program can do far less damage.
05Why should a program on a cloud server use a role instead of a stored password or long-lived key?
A role has permissions but no password. The cloud hands out short-lived credentials (for example, one hour by default for AssumeRole), so nothing permanent sits on the server.
المسرد
- IAM
- Identity and access management: the cloud service that decides who is asking and what they are allowed to do.
- Principal
- Any identity that can send a request to a cloud service: a person (a user) or a program (using a role).
- Authentication
- Proving who you are, for example with a password plus a one-time code (multi-factor authentication, MFA).
- Authorization
- Deciding whether an authenticated identity may do a given action on a given resource.
- Policy
- A JSON document of statements. Each statement has an Effect (Allow or Deny), an Action and a Resource.
- Implicit deny
- The default answer. A request is refused unless a policy allows it.
- Least privilege
- Giving each identity only the permissions its job needs, and nothing more.
- Role
- An identity with permissions but no password. Programs and people take it on and get temporary credentials that expire.
الملاحظات والمصادر
- The figure follows AWS IAM, simplified. Real evaluation also weighs resource-based policies, permissions boundaries, session policies and organization-wide controls, and statements can add Conditions. The rule "explicit deny wins, else an allow, else deny" still holds.
- The policy card is valid JSON and also a valid Python dict. The Python rule uses fnmatchcase for the * wildcard; real IAM matches action names without regard to case and does not use fnmatch.
- AssumeRole credentials last 3600 seconds (1 hour) by default, from 900 seconds up to the role's maximum session. On an EC2 server the role's credentials are delivered and rotated automatically.
- Google Cloud IAM grants roles to principals in allow policies; Azure role-based access control (RBAC) uses role assignments, and also has deny assignments.
- AWS IAM User Guide: How IAM works
- AWS IAM User Guide: Policy evaluation logic
- AWS IAM User Guide: Policies and permissions in IAM
- AWS IAM JSON policy elements: Version
- AWS IAM User Guide: Multi-factor authentication
- AWS IAM User Guide: IAM roles
- AWS STS API Reference: AssumeRole
- AWS IAM User Guide: Security best practices in IAM
- Service Authorization Reference: Amazon S3 actions and resources
- NIST CSRC glossary: least privilege
- Google Cloud: IAM overview
- Microsoft Learn: What is Azure role-based access control (Azure RBAC)?
اختبار يتاح بعد الخطوة الأخيرة.