Authenticate and continuously authorize API consumers: access control
has always involved authentication and authorization. Authentication
AuthN , involves identifying the requester of a given function or resource
and challenging that entity for authentication material or credentials.
Authorization AuthZ involves verifying whether that authenticated entity
actually has permissions to exercise a function or read, write, update, or
delete data. Traditionally, both were handled at the start of a session. In the
web world, and by extension APIs, sessions are stateless. The operating
environments of back-ends and front-ends are not guaranteed and often
ephemeral. Increasingly, environments are also prone to integrity issues or
compromise, hence the rise of zero trust architectures. As a result, you
must continuously verify whether a user or machine identity should have
access to a given resource and always presume the authenticated session
might be compromised. This approach requires analyzing behaviors of a
given session for an API consumer, and potentially terminating that session,
requiring step-up authentication, or blocking access as appropriate.
2.
Use modern authentication and authorization protocols: use newer
authentication protocols like OpenID Connect and authorization protocols.
Using sufficient authentication token lengths and entropy are also critically
important to mitigate risk of session guessing or brute forcing. JSON Web
Tokens JWT are a popular choice as a token format within OAuth2.
Two-factor authentication 2FA should also be in your arsenal for
authenticating users that consume APIs. 2FA challenges are delivered
through email, SMS, or Time-based One-time Password TOTP
authenticator apps. Certificate-based authentication is more common for
machine-to-machine communication and automation scenarios where it is
not technically feasible to prompt for authentication material. Mutual TLS
(mTLS is also prominent for microservice authN and authZ as seen within
Kubernetes and service mesh. Never rely on mechanisms like basic
authentication or digest authentication. Attacks against these older
authentication mechanisms are well documented, and they are trivial for
attackers to defeat.
Salt I API Security Best Practices I 21