Raxol.Auth (Raxol v0.2.0)

View Source

Authentication module for handling user authentication and authorization.

This module provides functionality for:

  • User authentication
  • Token generation and validation
  • Role-based access control
  • Session management

Summary

Functions

Cleans up a user session.

Creates a new session for an authenticated user. (Session logic currently commented out, returns :ok)

Retrieves user information by ID (Calls Accounts).

TODO: Review if needed, Accounts.get_user/1 exists Retrieves a user by their session ID. Returns the user or nil if not found or session is invalid.

Checks if a user has permission for a specific action (Placeholder).

Checks if a user has the required role.

Validates a session token and returns the associated user ID. WARNING: This is a placeholder and insecure. Needs proper implementation.

Functions

cleanup_user_session(session_id)

@spec cleanup_user_session(String.t()) :: :ok

Cleans up a user session.

create_user_session(user_id, metadata \\ %{})

@spec create_user_session(integer(), map()) :: :ok

Creates a new session for an authenticated user. (Session logic currently commented out, returns :ok)

get_user(user_id)

Retrieves user information by ID (Calls Accounts).

get_user_by_session(session_id)

TODO: Review if needed, Accounts.get_user/1 exists Retrieves a user by their session ID. Returns the user or nil if not found or session is invalid.

has_permission?(user, module, action)

Checks if a user has permission for a specific action (Placeholder).

has_role?(user_id, required_role)

Checks if a user has the required role.

validate_token(session_id, token)

Validates a session token and returns the associated user ID. WARNING: This is a placeholder and insecure. Needs proper implementation.