3.3 KiB
MCIAS Installation and Usage Guide
- MCIAS Installation and Usage Guide
MCIAS Installation and Usage Guide
Prerequisites
Before installing MCIAS, ensure you have the following prerequisites:
- Go 1.23 or later
- SQLite3
- golangci-lint (for development)
Installation
Clone the Repository
git clone git.wntrmute.dev/kyle/mcias
cd mcias
Install Dependencies
go mod download
Initialize the Database
MCIAS uses SQLite for data storage. To initialize the database:
go run main.go -init -db ./mcias.db
This command creates a new SQLite database file and initializes it with the schema defined in schema.sql
.
Running the Server
Basic Usage
To start the MCIAS server with default settings:
go run main.go -db ./mcias.db
By default, the server listens on port 8080.
Configuration Options
MCIAS supports the following command-line options:
-db <path>
: Path to the SQLite database file (default:mcias.db
)-addr <address>
: Address to listen on (default::8080
)-init
: Initialize the database and exit
Example with custom port:
go run main.go -db ./mcias.db -addr :9000
Building from Source
To build a binary:
go build -o mcias
Then run the binary:
./mcias -db ./mcias.db
Development
Running Tests
To run all tests:
go test ./...
Linting
To run the linter:
golangci-lint run
Using the API
Authentication with Password
To authenticate a user with a password:
curl -X POST http://localhost:8080/v1/login/password \
-H "Content-Type: application/json" \
-d '{
"version": "v1",
"login": {
"user": "username",
"password": "password"
}
}'
Authentication with Token
To authenticate a user with a token:
curl -X POST http://localhost:8080/v1/login/token \
-H "Content-Type: application/json" \
-d '{
"version": "v1",
"login": {
"user": "username",
"token": "your_token"
}
}'
Troubleshooting
Common Issues
-
Database errors: Ensure the database file exists and has the correct permissions.
# Check permissions ls -l mcias.db # Fix permissions if needed chmod 644 mcias.db
-
Port already in use: If the port is already in use, specify a different port with the
-addr
flag.go run main.go -db ./mcias.db -addr :8081
- Authentication failures: Ensure you're using the correct username and password/token.
Logging
MCIAS logs to stdout by default. To capture logs to a file:
go run main.go -db ./mcias.db > mcias.log 2>&1
Security Best Practices
-
Production Deployment:
- Use HTTPS in production
- Set up proper firewall rules
- Run the service with minimal privileges
-
Database Security:
- Regularly backup the database
- Restrict file permissions on the database file
- Consider encrypting the database file at rest
-
User Management:
- Implement strong password policies
- Regularly rotate tokens
- Monitor for suspicious authentication attempts