From 6b397d15d7d5ccf6213d759f17a70b4c6775ad2a Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 29 Dec 2020 01:26:49 -0500 Subject: [PATCH 1/5] fine tuning UI --- src/BirdsiteLive/Views/Home/Index.cshtml | 2 +- src/BirdsiteLive/Views/Users/Index.cshtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BirdsiteLive/Views/Home/Index.cshtml b/src/BirdsiteLive/Views/Home/Index.cshtml index 866a295..340f982 100644 --- a/src/BirdsiteLive/Views/Home/Index.cshtml +++ b/src/BirdsiteLive/Views/Home/Index.cshtml @@ -19,7 +19,7 @@ *@
@**@ - +
diff --git a/src/BirdsiteLive/Views/Users/Index.cshtml b/src/BirdsiteLive/Views/Users/Index.cshtml index 2f3c727..a8fbc34 100644 --- a/src/BirdsiteLive/Views/Users/Index.cshtml +++ b/src/BirdsiteLive/Views/Users/Index.cshtml @@ -5,7 +5,7 @@ } -
+
@*
*@
From 47649392eda7cc442fcb77109501f6f9c236142d Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 29 Dec 2020 02:12:44 -0500 Subject: [PATCH 2/5] added user not found page --- src/BirdsiteLive/Controllers/UsersController.cs | 12 +++++++++++- src/BirdsiteLive/Views/Users/UserNotFound.cshtml | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/BirdsiteLive/Views/Users/UserNotFound.cshtml diff --git a/src/BirdsiteLive/Controllers/UsersController.cs b/src/BirdsiteLive/Controllers/UsersController.cs index dd1b081..893e0c5 100644 --- a/src/BirdsiteLive/Controllers/UsersController.cs +++ b/src/BirdsiteLive/Controllers/UsersController.cs @@ -36,21 +36,31 @@ namespace BirdsiteLive.Controllers } #endregion + [Route("/users")] + public IActionResult Index() + { + var r = Request.Headers["Accept"].First(); + if (r.Contains("application/activity+json")) return NotFound(); + return View("UserNotFound"); + } + [Route("/@{id}")] [Route("/users/{id}")] public IActionResult Index(string id) { var user = _twitterService.GetUser(id); - if (user == null) return NotFound(); var r = Request.Headers["Accept"].First(); if (r.Contains("application/activity+json")) { + if (user == null) return NotFound(); var apUser = _userService.GetUser(user); var jsonApUser = JsonConvert.SerializeObject(apUser); return Content(jsonApUser, "application/activity+json; charset=utf-8"); } + if (user == null) return View("UserNotFound"); + var displayableUser = new DisplayTwitterUser { Name = user.Name, diff --git a/src/BirdsiteLive/Views/Users/UserNotFound.cshtml b/src/BirdsiteLive/Views/Users/UserNotFound.cshtml new file mode 100644 index 0000000..ec0928f --- /dev/null +++ b/src/BirdsiteLive/Views/Users/UserNotFound.cshtml @@ -0,0 +1,11 @@ +@{ + ViewData["Title"] = "User"; +} + + \ No newline at end of file From e79086883ac6ee5aeb78d8a0b20bc12a95c972a3 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 29 Dec 2020 19:11:48 -0500 Subject: [PATCH 3/5] first draft --- INSTALLATION.md | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 INSTALLATION.md diff --git a/INSTALLATION.md b/INSTALLATION.md new file mode 100644 index 0000000..2463e8e --- /dev/null +++ b/INSTALLATION.md @@ -0,0 +1,139 @@ +# Installation + +## Prerequisites + +You will need a Twitter API key to make BirdsiteLIVE working. First create an **Standalone App** in the [Twitter developer portal](https://developer.twitter.com/en/portal/projects-and-apps) and retrieve the API Key and API Secret Key. + +## Server prerequisites + +Your instance will need [docker](https://docs.docker.com/engine/install/) and [docker-compose](https://docs.docker.com/compose/install/) installed and working. + +## Setup + +Download the [docker-compose file](https://github.com/NicolasConstant/BirdsiteLive/blob/master/docker-compose.yml): + +``` +curl https://raw.githubusercontent.com/NicolasConstant/BirdsiteLive/master/docker-compose.yml --output docker-compose.yml +``` + +Then edit file: + +``` +sudo nano docker-compose.yml +``` + +### Attributes to change in the docker-compose file + +#### Personal info + +* `Instance:Domain` the domain name you'll be using, for example use `birdsite.live` for the URL `https://birdsite.live` +* `Instance:AdminEmail` the admin's email, will be displayed in the instance /.well-known/nodeinfo endpoint +* `Twitter:ConsumerKey` the Twitter API key +* `Twitter:ConsumerSecret` the Twitter API secret key + +#### Database credentials + +The database credentials must be changed the same way in the **server** and **db** section. + +* database name: + * `Db:Name` + * `POSTGRES_DB` +* database user name: + * `Db:User` + * `POSTGRES_USER` +* database user password: + * `Db:Password` + * `POSTGRES_PASSWORD` + +## Startup + +Launch the app with: + +``` +docker-compose up -d +``` + +By default the app will be available on the port 5000 + +## Nginx + +On a Debian based distrib: + +``` +sudo apt update +sudo apt install nginx +``` + +Check nginx status: + +``` +sudo systemctl status nginx +``` + +### Create nginx configuration + +Create your nginx configuration + +``` +sudo nano /etc/nginx/sites-enabled/{your-domain-name.com} +``` + +And fill your service block as follow: + +``` +server { + listen 80; + server_name {your-domain-name.com}; + location / { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} +``` + +Save and start/restart your Nginx service + +``` +sudo service nginx start +# or restart it if its already started +sudo service nginx restart +``` + +### Secure your hosted application with SSL + +After having a domain name pointing to your instance, install and setup certbot: + +``` +sudo apt install certbot python3-certbot-nginx +sudo certbot --nginx -d {your-domain-name.com} +``` + +Make sure you're redirecting all traffic to https when asked. + +Finally check that the auto-revewal will work as espected: + +``` +sudo certbot renew --dry-run +``` + +### Set the firewall + +Make sure you're securing your firewall correctly: + +``` +sudo ufw app list +sudo ufw allow 'Nginx Full' +sudo ufw allow 22/tcp +sudo ufw allow 80/tcp +sudo ufw allow 443/tcp +sudo ufw enable +sudo ufw status +``` + +You should now have an up and running BirdsiteLIVE instance! From 9dcb96dc53f1b83aa05c70d729fb5ab31c115629 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 29 Dec 2020 19:28:51 -0500 Subject: [PATCH 4/5] better curl call --- INSTALLATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index 2463e8e..d1acd82 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -13,7 +13,7 @@ Your instance will need [docker](https://docs.docker.com/engine/install/) and [d Download the [docker-compose file](https://github.com/NicolasConstant/BirdsiteLive/blob/master/docker-compose.yml): ``` -curl https://raw.githubusercontent.com/NicolasConstant/BirdsiteLive/master/docker-compose.yml --output docker-compose.yml +sudo curl -L https://raw.githubusercontent.com/NicolasConstant/BirdsiteLive/master/docker-compose.yml -o docker-compose.yml ``` Then edit file: From c0bf662f457b86b01a0a33eca4106e697b6ffa7a Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Tue, 29 Dec 2020 20:11:59 -0500 Subject: [PATCH 5/5] added state of dev + various infos --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05f451e..5744ec6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,27 @@ ![Test](https://github.com/NicolasConstant/BirdsiteLive/workflows/.NET%20Core/badge.svg?branch=master&event=push) -# BirdsiteLive -An ethical ActivityPub bridge from Twitter +# BirdsiteLIVE + +## About + +BirdsiteLIVE is an ActivityPub bridge from Twitter, it's mostly a pet project/playground for me to handle ActivityPub concepts. Feel free to deploy your own instance (especially if you plan to follow a lot of users) since it use a proper Twitter API key and therefore will have limited calls ceiling (it won't scale, and it's by design). + +## State of development + +The code is pretty messy and far from a good state, since it's a playground for me the aim was to understand some AP concepts, not provide a good state-of-the-art codebase. But I might refactor it to make it cleaner. + +## Official instance + +You can find an official (and temporary) instance here: [beta.birdsite.live](https://beta.birdsite.live). This instance can disapear at any time, if you want a long term instance you should install your own or use another one. + +## Installation + +Please follow [those instructions](https://github.com/NicolasConstant/BirdsiteLive/blob/master/INSTALLATION.md) + +## License + +This project is licensed under the AGPLv3 License - see [LICENSE](https://github.com/NicolasConstant/BirdsiteLive/blob/master/LICENSE) for details + +## Contact + +You can contact me via ActivityPub [here](https://social.nicolas-constant.com/NicolasConstant).