The bmatch.gateway
microservice serves as a gateway for various applications, ensuring routing, as well as user registration, authentication, and profile management.
- Gateway: Routes requests to the appropriate microservices.
- Registration & Authentication: Handles user account creation and authentication.
- Profile Management: Fetches and stores user profiles in Redis.
/api/user/login
- User login./api/user/create
- Register a new user./api/user/profile
- Fetch a user's profile./api/user/**
- Routes user-related requests to the bmatch-user microservice.
- Routes prefixed with
/api/admin/**
require ADMINISTRATOR role. - Paths
/api/user/create
,/api/user/login
, and/api/user/profile
are publicly accessible. - Access to
/api/user/**
and/api/restaurant/**
requires PLAYER authority. /actuator/health
is publicly accessible for service health checks.
The microservice configuration uses the following environment variables:
-
DB_USERNAME
: Database username. Default -bmatch
.DB_PASSWORD
: Database password. Default -newpassword
.DB_SCHEME
: Database name. Default -bmatch
.DB_HOST
: Database host. Default -localhost
.
-
REDIS_PORT
: Redis port. Default -6379
.REDIS_HOST
: Redis host. Default -localhost
.
-
IS_PROD
: Indicates if the environment is production. Default - false.JWT_TOKEN
: Secret key for JWT token. Default -YourSecretKeyShouldBeVerySecureAndNotPublic
.
-
SSL_KEYSTORE_PASSWORD
: Keystore password. Default -mypassword
SSL_KEYSTORE_FILE
: Keystore path. Default -file:./keystore.jks
-
SPRING_CLOUD_CONSUL_HOST
: Consul host. Default -localhost
.
To generate a self-signed SSL certificate for development or testing:
- Generate a keystore:
keytool -genkeypair -v -keystore keystore.jks -keyalg RSA -keysize 2048 -validity 365 -alias bmatch.gateway -dname "CN=localhost, OU=MyOrg, O=MyOrg, L=City, ST=State, C=Country" -storepass mypassword -keypass mypassword
- For API testing tools like Insomnia that require a PEM format:
a. Export the certificate from keystore in DER format:b. Convert DER format to PEM:keytool -export -keystore keystore.jks -alias bmatch.gateway -file mycert.der -storepass mypassword
openssl x509 -inform der -in mycert.der -out mycert.pem
- Clone the repository.
- Ensure all required dependencies are installed and appropriate environment variables are set.
- Launch the microservices (Redis, Consul, Postgresql) using docker
-
gradle clean build -x test --no-daemon