Skip to content

SudoSOS Back-end API / authentication / KeyAuthenticator

Class: KeyAuthenticator ​

The Key Authenticator is used for API key-based authentication in SudoSOS. This authentication method allows programmatic access to the system using pre-generated API keys instead of user credentials.

Key Authentication is a hash-based authentication method. This means that the API key is hashed using bcrypt and stored in the database, and later compared against the input during authentication attempts.

Key Authentication Flow ​

  1. Client sends a request to the /authentication/key endpoint with user ID and API key.
  2. Authentication Controller looks up the user by ID.
  3. Authentication Controller retrieves the associated KeyAuthenticator.
  4. Authentication Service compares the provided key against the stored hash.
  5. Authentication Controller returns a JWT token if authentication succeeds.

Use Cases ​

  • Automated systems that need to access the SudoSOS API
  • Third-party integrations
  • Scripts and tools that require programmatic access
  • Testing and development environments

Extends ​

Constructors ​

Constructor ​

ts
new KeyAuthenticator(): KeyAuthenticator;

Returns ​

KeyAuthenticator

Inherited from ​

HashBasedAuthenticationMethod.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
createdAtreadonlyDateThe creation date of the object.HashBasedAuthenticationMethod.createdAt
hashpublicstring-HashBasedAuthenticationMethod.hash
updatedAtreadonlyDateThe last update date of the object.HashBasedAuthenticationMethod.updatedAt
userpublicUser-HashBasedAuthenticationMethod.user
userIdpublicnumber-HashBasedAuthenticationMethod.userId
versionreadonlynumberThe current version of the object.HashBasedAuthenticationMethod.version