Skip to content

Getting Started

Muhammet Arslan edited this page Aug 31, 2023 · 5 revisions

NatterNet: Getting Started

Welcome to the NatterNet project! This guide will walk you through the steps required to get the project up and running on your local machine.

Table of Contents

  1. Prerequisites
  2. Installation
  3. Setting Up RSA Keys for JWT
  4. Starting the Project

Prerequisites


Installation

Before you start, make sure you have Docker and Docker Compose installed on your machine. If not, you can download them from Docker's official site.

  1. Clone the Repository

    git clone https://github.com/iammuho/NatterNet.git
  2. Navigate to the Project Folder

    cd NatterNet

Setting Up RSA Keys for JWT

To secure the API with JWT (JSON Web Tokens), you'll need to generate a pair of RSA keys. Below is the related code snippet:

  1. Generate RSA keys for JWT

    Before you start the server, you'll need to generate RSA keys that will be used for signing and verifying JWT tokens.

    1.Open your terminal and navigate to the project's root directory. 2. Run the RSA key generation script with root privileges:

    sudo bash hack/rsa.sh

    This script will generate RSA public and private keys and place them in the /etc/ssl/certs/ directory. The script also sets the necessary read permissions.

  2. Generate Pairs

Generates a key pair, either for signing/verification or encryption/decryption. Generated keys will be written to the current directory.

```go
    # Generate keys for signing (for RSA-PSS)
    jose-util generate-key --use sig --alg RS256

    # Generate keys for signing (for EdDSA)
    jose-util generate-key --use sig --alg EdDSA

    # Generate keys for encryption (for RSA-OAEP)
    jose-util generate-key --use enc --alg RSA-OAEP

    # Generate keys for encryption (for ECDH-ES)
    jose-util generate-key --use enc --alg ECDH-ES+A128KW
```
  1. Environment Variables

    Place these files in /etc/ssl/certs or update the environment variables JWT_PUBLIC_KEY_PATH and JWT_PRIVATE_KEY_PATH to point to the appropriate file paths.

    JWT_PUBLIC_KEY_PATH=/path/to/public.pem
    JWT_PRIVATE_KEY_PATH=/path/to/private.pem

Starting the Project

  1. Run Docker Containers

    This command will start the services defined in docker-compose.yml under the project name natternet.

    docker-compose -p natternet up -d
  2. Start the NatterNet Application

    cd cmd/app/ && go run .

    At this point, your NatterNet application should be running, and you can access it in your browser at the specified address (e.g., http://localhost:8080).

  3. Access MongoDB via Mongo-Express

    You can access the Mongo-Express web interface at http://localhost:8081.

  4. Stop the Docker Services

    When you are done with development, you can stop the Docker services with the following command:

    docker-compose -p natternet down

Feel free to contribute and let us know if you have any questions or issues.

Clone this wiki locally