Crate authentication

Source
Expand description

§Authentication Module

The Authentication module provides user and group management functionality for the Xila operating system. It handles user authentication, password hashing, and secure storage of user/group information.

§Features

  • User Management: Create, authenticate, and manage user accounts
  • Group Management: Create and manage user groups
  • Password Security: Secure password hashing using SHA-512 with salt
  • File-based Storage: Persistent storage of user and group data in JSON format
  • Async Operations: All operations are asynchronous for better performance

§Usage

The module provides functionality to:

  • Load existing users and groups from the filesystem
  • Authenticate users with username/password
  • Create new users and groups
  • Change user passwords and usernames
  • Hash passwords securely with salt generation

§File Structure

  • Users are stored in /System/Users/ directory
  • Groups are stored in /System/Groups/ directory
  • Each user/group has their own JSON file containing their data
  • Random salt generation uses /devices/random device

Structs§

Group
Represents a user group with associated metadata and member list.
User
Represents a user account with all associated metadata.

Enums§

Error
Comprehensive error enumeration for authentication operations.

Functions§

authenticate_user
Authenticates a user with their username and password.
change_user_name
Changes a user’s username by updating their user file.
change_user_password
Changes a user’s password by generating a new salt and hash.
create_group
Creates a new group with the specified parameters.
create_user
Creates a new user account with the specified parameters.
get_group_file_path
Constructs the file system path for a group’s data file.
get_user_file_path
Constructs the file system path for a user’s data file.
load_all_users_and_groups
Loads all users and groups from the filesystem into memory.
read_group_file
Reads and parses a group file from the filesystem.
read_user_file
Reads and parses a user file from the filesystem.

Type Aliases§

Result
Result type alias for authentication operations.