Common API Authentication and Authorization Mistakes
Common mistakes in API authentication and authorization usually begin with a blurred boundary between three questions: who is calling, what may they do, and which records may they act on. Authentication answers the first question, while authorisation covers the other two. When those controls collapse into a single API-key check, a valid caller can reach another customer’s data or trigger an action outside their remit. The risk applies equally to an internal tool and a consumer finance or health platform.
These failures often remain invisible because the endpoint returns familiar data and the requester already possesses a valid credential. A secure design carries identity and entitlement through every layer, including gateways, controllers, queues, and downstream services. It also assumes tokens, keys, browser sessions, and third-party callbacks can fail. The practical goal is not maximal complexity; it is a system in which each accepted request has a clear, reviewable reason to be accepted.
Separating Identity, Authentication, and Authorization
Start with a documented identity model that distinguishes human users, workforce accounts, customers, devices, and machine-to-machine services. OAuth 2.0 access tokens commonly represent a delegated user or service principal, while an API key identifies a client rather than an end user. These identities need different lifecycle rules. A staff member may authenticate through a corporate identity provider, retain access during employment, and lose it immediately when disabled. A service account used by a scheduled job may authenticate with a client certificate or workload identity and require its own rotation schedule.
Authentication establishes a credible subject, but it does not automatically establish entitlement. A claims file containing a role is evidence supplied by the token issuer, not proof that the role still matches current business rules. A user may have changed teams, moved from one customer account to another, or lost approval for a sensitive action. Applications should derive the effective actor and tenant from trusted server-side context instead of accepting an arbitrary tenant identifier from the request body.
Authorisation then needs both action-level and resource-level checks. Action-level checks determine whether an actor may call a method such as exporting invoices. Resource-level checks determine whether that actor may access the specific invoice, patient record, or payment represented by the URL. Confusing the two produces broken object-level authorisation: the caller can invoke an export function, yet the function exports records belonging to someone else. Secure defaults, explicit ownership checks, and separation of duties prevent this form of privilege escalation.
Weak Tokens and Unsafe Secret Storage
JWT validation often fails through small omissions. A service may decode a token without verifying its signature, accept the token’s stated algorithm without an allowlist, or ignore expiry and audience claims. It may also trust a token merely because its issuer looks familiar. Proper validation checks the signature against the correct key, confirms the expected issuer and audience, and rejects expired or not-yet-valid tokens. Security teams should also account for clock skew and revoke access when a session or service credential is known to be compromised.
API keys and signing secrets need the same discipline. A key committed to a public repository can be harvested by automated scanners within minutes, while a shared key embedded in a mobile application should be considered exposed. Secrets belong in an approved secrets manager or vault, with access limited to the workloads that need them. Rotation should be tested, not merely documented, and old credentials should remain invalid after replacement. Hard-coded fallback secrets are especially dangerous because they let an application continue operating after its secret store becomes unavailable.
Browser storage introduces another set of risks. Long-lived access tokens in localStorage can be stolen by a cross-site scripting attack, while tokens placed in query strings may appear in browser history, analytics tools, proxy logs, and support screenshots. Where browser-based sessions are appropriate, cookies can carry useful protections such as Secure, HttpOnly, and an appropriate SameSite policy. Short-lived tokens should remain in memory when possible, refresh tokens should rotate after use, and logout or revocation must invalidate the relevant server-side session.
Missing Role, Tenant, and Object Checks
Role names are often treated as a complete permission system. Labels such as admin, manager, and operator may look convincing while failing to express the actual capabilities an application needs. A role can also become dangerously broad after several product teams add exceptions to it. Permission checks should use explicit capabilities such as invoice.read, invoice.approve, or customer.export, then map those capabilities to roles according to current business policy. This makes reviews clearer and reduces the temptation to grant an administrator account to solve a narrow problem.
Tenant isolation requires particular care in multi-tenant services. A caller should never be able to change a customer identifier and retrieve another tenant’s record simply because the identifier is syntactically valid. Every query should include the authorised tenant context, and every returned object should be checked against that context. IDs should be treated as references rather than permissions. This approach reflects the Australian “fair go” expectation: access is granted where it is genuinely required, without opening unrelated records as a side effect.
Authorisation tests should combine roles, tenants, resource ownership, and request state. A role check alone may permit a manager to approve a refund, even though the refund belongs to a different branch. A direct-object check alone may allow an employee to read a record outside their region. Automated tests should cover allowed requests, missing permissions, wrong tenants, guessed identifiers, disabled accounts, and actions that become invalid after an earlier step. Service accounts need the same scrutiny because unattended jobs often receive broad access that no human would need.
Fragile Integrations and Misleading Errors
Authentication errors must communicate the right condition without revealing sensitive details. A missing or invalid credential normally produces 401 Unauthorized, while a valid caller lacking permission receives 403 Forbidden. Returning 403 for every failure can conceal an expired token and encourage clients to retry indefinitely. Returning detailed database or cryptographic errors helps an attacker classify weaknesses. Error responses should use stable error codes, include a request identifier, and avoid exposing tokens, internal hostnames, stack traces, or authorisation rules.
Retry behaviour can turn an ordinary expiry event into an outage. Clients that immediately retry every failed request create a surge against the authentication service and may lock out legitimate users. Retries should use bounded exponential backoff, respect Retry-After, and occur only for transient failures. A client that receives 401 should refresh its credential once, then stop if the new credential still fails. Distributed systems also need a shared clock strategy, since unexplained authorisation errors frequently come from unsynchronised servers rather than incorrect permissions.
OAuth integrations require exact redirect handling, appropriate scopes, and protection against cross-site request forgery. Redirect URIs should be registered precisely, with wildcard matching avoided. Authorization-code flows should use PKCE, and the state parameter should validate the session that initiated the request. For public clients, the client secret cannot protect the flow because an attacker can extract it from the application. Webhooks and partner APIs also require signature verification, replay protection, timestamp checks, and secret rotation.
Engineering teams sometimes park vendor links in chat applications, and this Telegram bookmarking workflow illustrates one personal filing method. Such tools can help organise non-sensitive reading, but tokens, customer records, recovery codes, and private keys should never be pasted into them. Bookmarks should point towards approved internal documentation, not replace a secrets vault or incident-response process.
Australian Privacy and Operational Realities
Australian privacy obligations affect what an API can collect, combine, expose, and retain. Many organisations are covered by the Privacy Act 1988 and the Australian Privacy Principles overseen by the Office of the Australian Information Commissioner. API telemetry often contains more personal information than teams realise: IP addresses, user agents, support identifiers, search terms, and request payloads may all enter application logs. Data minimisation, defined retention periods, controlled access, and accurate privacy notices are therefore part of secure API design, particularly where identifiers can be linked across systems.
State and territory legislation can add requirements, especially for health information. A service supporting a NSW Health workflow may encounter different obligations from one supporting a Victorian hospital, even when both use common clinical standards. Security controls should reflect the jurisdictions in which the organisation operates rather than assuming one national rule covers every record. The Australian Signals Directorate’s Essential Eight also provides a useful baseline for Australian government and connected organisations, covering application security, patching, access control, multifactor authentication, logging, and tested recovery arrangements.
Local commerce adds practical constraints. Sydney fintech companies and Melbourne software businesses commonly connect services such as Shopify, Stripe, Xero, and MYOB while handling Australian-dollar amounts and GST records. These integrations often cross accounting, payment, and customer-support boundaries, creating many places where one service identity could be mistaken for authority over another. API contracts should make currency, tax, and organisation identifiers explicit, and partners should receive only the records required for their function.
Support hours create another operational consideration. A Perth customer may contact a Brisbane-based team before the Sydney office opens, while Melbourne systems continue processing jobs throughout the night. Token expiry, delayed revocation, and key rotation therefore need monitoring that does not depend on one business day. Teams should measure rejected requests, refresh failures, credential age, unusual access patterns, and authorisation denials by tenant and capability. A trustworthy API makes every request attributable, appropriately scoped, observable, and revocable, which is the real measure of successful access control.