-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✒️ refactor(like-service, docs): Document like-service, refactor env …
…variables
- Loading branch information
1 parent
5ad0ce1
commit efe5319
Showing
15 changed files
with
158 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# SQL injection | ||
|
||
Unguard has two SQL injection vulnerabilities: | ||
Unguard has three SQL injection vulnerabilities: | ||
* [One in the Java `profile-service`](./SQLI-PROFILE-SERVICE-H2.md), which is exploitable through the user biography and allows you to access the h2 database. | ||
* [One in the Golang `status-service`](./SQLI-STATUS-SERVICE-MARIADB.md), which is exploitable through the search bar on the Users page and allows you to access the MariaDB database. | ||
* [One in the PHP `like-service`](./SQLI-LIKE-SERVICE-REMOVE-LIKE.md), which allows you to remove another user's like on a given post if you send the right parameters. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,86 @@ | ||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p> | ||
|
||
<p align="center"> | ||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a> | ||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a> | ||
</p> | ||
|
||
## About Laravel | ||
|
||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: | ||
|
||
- [Simple, fast routing engine](https://laravel.com/docs/routing). | ||
- [Powerful dependency injection container](https://laravel.com/docs/container). | ||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. | ||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). | ||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations). | ||
- [Robust background job processing](https://laravel.com/docs/queues). | ||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). | ||
|
||
Laravel is accessible, powerful, and provides tools required for large, robust applications. | ||
|
||
## Learning Laravel | ||
|
||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. | ||
|
||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. | ||
|
||
## Laravel Sponsors | ||
|
||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). | ||
|
||
### Premium Partners | ||
|
||
- **[Vehikl](https://vehikl.com/)** | ||
- **[Tighten Co.](https://tighten.co)** | ||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** | ||
- **[64 Robots](https://64robots.com)** | ||
- **[Cubet Techno Labs](https://cubettech.com)** | ||
- **[Cyber-Duck](https://cyber-duck.co.uk)** | ||
- **[Many](https://www.many.co.uk)** | ||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** | ||
- **[DevSquad](https://devsquad.com)** | ||
- **[OP.GG](https://op.gg)** | ||
|
||
## Contributing | ||
|
||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). | ||
|
||
## Code of Conduct | ||
|
||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). | ||
|
||
## Security Vulnerabilities | ||
|
||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. | ||
|
||
## License | ||
|
||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). | ||
# Like Service | ||
|
||
Provides REST endpoints for retrieving and updating like counts for posts in MariaDB: | ||
* `POST like-service/like-service/like-delete` | ||
``` | ||
Request body: | ||
{ | ||
"postId": 123 | ||
} | ||
``` | ||
* `POST like-service/like-service/like-post` | ||
``` | ||
Request body: | ||
{ | ||
"postId": 123 | ||
} | ||
``` | ||
* `GET like-service/like-service/like-count/{postId}` | ||
``` | ||
Response: | ||
{ | ||
"likeCount": 123, | ||
"userLiked": true | ||
} | ||
`````` | ||
* `GET like-service/like-service/like-count?postIds=1&postIds=2&postIds=3&postIds=4...` | ||
``` | ||
Response: | ||
{ | ||
"likeCounts": [ | ||
{"postId": 1, "likeCount": 123}, | ||
{"postId": 2, "likeCount": 456}, | ||
{"postId": 3, "likeCount": 789}, | ||
{"postId": 4, "likeCount": 135}, | ||
... | ||
], | ||
"likedPosts": [ | ||
{"postId": 1}, | ||
{"postId": 3}, | ||
... | ||
] | ||
} | ||
``` | ||
All the endpoints require that a JWT cookie be sent for authentication with the the `user-auth-service`. This cookie is obtained by logging in and links the requests to a user ID. | ||
# How to run locally | ||
The Like Service can either be run using `skaffold dev` (see [DEV-GUIDE](../../docs/DEV-GUIDE.md)), or it can be run locally, provided that you have the following requirements installed. | ||
## Requirements | ||
* PHP 8.0 with `opentelemetry` and MySQL (`mysqli`, `pdo`, `pdo_mysql`) extensions installed | ||
* Composer | ||
* MariaDB instance (see [user-auth-service README](../user-auth-service/README.md) for setting it up) | ||
## Environment Variables | ||
The following environment variables need to be set: | ||
| Name | Example Value | Description | | ||
|---------------------------|-----------------------------------|-------------------------------------------------------------| | ||
| SERVICE_NAME | unguard-like-service | Name of the service | | ||
| API_PATH | /like-service | Api entrypoint path | | ||
| SERVER_PORT | 8000 | The port that the server will run on | | ||
| USER_AUTH_SERVICE_ADDRESS | unguard-user-auth-service-service | Change to hostname/IP of user-auth-service instance | | ||
| DB_HOST | localhost | Address of MariaDB instance | | ||
| DB_PORT | 3306 | Port of MariaDB instance | | ||
| DB_DATABASE | likeDb | Database to create and use on the MariaDB instance | | ||
| DB_USERNAME | root | Username of the MariaDB user | | ||
| MARIADB_PASSWORD | | Password of the MariaDB user | | ||
| JAEGER_DISABLED | true | Set to 'false' if you have a Jaeger instance running | | ||
| JAEGER_COLLECTOR_HOST | collector | Change to hostname/IP of your Jaeger collector | | ||
| JAEGER_PORT | 4318 | The jaeger collector port for HTTP OTLP traffic | | ||
| JAEGER_SERVICE_NAME | unguard-like-service | Name that will be used for the service in the Jaeger traces | | ||
## Setup | ||
Install the required packages: | ||
``` | ||
composer install | ||
``` | ||
Create the database and create tables: | ||
``` | ||
php artisan make:database | ||
php artisan migrate:fresh | ||
``` | ||
Run Laravel: | ||
``` | ||
php artisan serve | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters