Skip to content

moncalvillo/auth-ms

Repository files navigation

Auth MS

Welcome to the Auth MS repository, a robust authentication microservice designed to operate as a Software as a Service (SaaS) solution. This service provides secure authentication capabilities via API calls, eliminating the need for local installations.

Features

  • Application-based Authentication: Register applications to obtain unique credentials.
  • Secure API Integration: Easily integrate with various platforms using provided endpoints.
  • Scalable and Modular: Designed with scalability and maintainability in mind.

Requirements

  • Node.js: Version 16 or higher.
  • Docker: Installed and running (optional but recommended).
  • Environment Variables: Defined in an .env file (use .env.template as a reference).

Getting Started

1. Clone the Repository

git clone <repository-url>
cd auth-ms

2. Install Dependencies

npm install

3. Configure Environment Variables

  1. Copy the .env.template file to .env:
    cp .env.template .env
  2. Edit .env to include your specific configuration values.

4. Run the Application

Locally

npm start

Using Docker

  1. Build the Docker image:
    docker-compose build
  2. Run the container:
    docker-compose up

API Usage

Registering an Application

Endpoint

  • Create Application: POST /api/applications

Request Body

{
  "name": "MyApp",
  "description": "Description of MyApp"
}

Response Example

{
  "id": "unique-id",
  "name": "MyApp",
  "credentials": {
    "clientId": "client-id",
    "clientSecret": "client-secret"
  }
}

Authentication

Endpoint

  • Authenticate User: POST /api/auth

Request Body

{
  "clientId": "client-id",
  "clientSecret": "client-secret",
  "username": "user",
  "password": "pass"
}

Response Example

{
  "token": "jwt-token",
  "expiresIn": 3600
}

Other Endpoints

For a complete list of endpoints and their usage, refer to the API documentation (future feature).

Development and Contribution

Local Development

  1. Use TypeScript for all development.
  2. Follow the existing folder structure:
    • src/core: Core business logic.
    • src/providers: Service integrations.
    • src/utils: Utility functions.
    • src/shared: Shared components and configurations.

Running Tests

Add and run tests to ensure functionality:

npm test

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a detailed explanation of your changes.

Roadmap

  • Implement detailed API documentation.
  • Add unit and integration tests.
  • Enhance security measures, such as rate limiting and IP whitelisting.
  • Introduce multi-factor authentication (MFA).

License

This project is licensed under the MIT License.

About

Authentication micro service.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages