Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Apr 8, 2023
2 parents e6809de + ac601ff commit 6537a92
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 58 deletions.
65 changes: 65 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ chrono = {version = "0.4.23", default-features=false, features = ["serde"]}
actix-web-actors = "4.2.0"
actix-cors="0.6.4"
rss = "2.0.2"
frankenstein = "0.24.1"
regex = "1.7.1"
diesel = { version = "2.0.3", features = ["sqlite", "returning_clauses_for_sqlite_3_35", "chrono", "r2d2"] }
r2d2 = "0.8.10"
Expand Down
38 changes: 5 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ volumes:
podgrab-db:
```
# Auth
## Proxy
Several Auth methods are described here: [AUTH.md](docs/AUTH.md)
## Requirements
- Set the `SERVER_URL` environment variable to the url of the proxy.
- Turn on websocket support in your proxy
# Hosting
→ You won't be able to use your service via the plain local url as the websocket connection will fail.

If the SERVER_URL starts with
- https => Secured Websocket (wss)
- http => Unsecured Websocket (ws)
Hosting options are described here: [HOSTING.md](docs/HOSTING.md)
# Environment Variables
Expand All @@ -75,30 +70,6 @@ If the SERVER_URL starts with
| DATABASE_URL | URL of the database | sqlite://./db/podcast.db |
## Basic Auth
Basic Auth is not required. If you use a reverse proxy like nginx you can use a better form that is also able to save passwords in your phone.
If you decide to use basic auth you need to set all three variables below. Otherwise, the container will crash with an error message as a safety measure.

| Variable | Description |
|------------|-----------------------------------------------------------------------------|
| BASIC_AUTH | Set to true if you want to use basic auth |
| USERNAME | Username for basic auth |
| PASSWORD | Password for basic auth |

## OIDC
PodFetch also supports OIDC authentication. If you want to use it you need to set the following variables.

If you enable it you need to disable BASIC_AUTH as it is not possible to use both at the same time.

| Variable | Description | example |
|-------------------|---------------------------------------|-----------------------------------------------------------------|
| OIDC_AUTH | Flag if OIDC should be enabled | true |
| OIDC_AUTHORITY | The url of the OIDC authority. | Keycloak Master <keycloak-url/realms/master |
| OIDC_CLIENT_ID | The client id of the OIDC client. | podfetch |
| OIDC_REDIRECT_URI | The client secret of the OIDC client. | <your-server-url>/ui/login |
| OIDC_SCOPE | The scope of the oidc token | This has a default value of "openid profile email" |
| OIDC_JWKS | The JWKS token uri | For Keycloak it is /realms/master/protocol/openid-connect/certs |
|
# UI
## Audio Player
Expand Down Expand Up @@ -155,5 +126,6 @@ After successful setup you should see on the settings page a green checkmark nex
- [x] Add retrieving podcasts from Podcastindex.org.
- [x] Basic Auth.
- [x] Import from OPML file.
- [x] Telegram Bot API to get alerted when new episodes are downloaded.
- [ ] Like episodes.
- [ ] Delete podcasts.
27 changes: 27 additions & 0 deletions docs/AUTH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Basic Auth
Basic Auth is not required. If you use a reverse proxy like nginx you can use a better form that is also able to save passwords in your phone.
If you decide to use basic auth you need to set all three variables below. Otherwise, the container will crash with an error message as a safety measure.

| Variable | Description |
|------------|-----------------------------------------------------------------------------|
| BASIC_AUTH | Set to true if you want to use basic auth |
| USERNAME | Username for basic auth |
| PASSWORD | Password for basic auth |





## OIDC
PodFetch also supports OIDC authentication. If you want to use it you need to set the following variables.

If you enable it you need to disable BASIC_AUTH as it is not possible to use both at the same time.

| Variable | Description | example |
|-------------------|---------------------------------------|-----------------------------------------------------------------|
| OIDC_AUTH | Flag if OIDC should be enabled | true |
| OIDC_AUTHORITY | The url of the OIDC authority. | Keycloak Master <keycloak-url/realms/master |
| OIDC_CLIENT_ID | The client id of the OIDC client. | podfetch |
| OIDC_REDIRECT_URI | The client secret of the OIDC client. | <your-server-url>/ui/login |
| OIDC_SCOPE | The scope of the oidc token | This has a default value of "openid profile email" |
| OIDC_JWKS | The JWKS token uri | For Keycloak it is /realms/master/protocol/openid-connect/certs |
28 changes: 28 additions & 0 deletions docs/HOSTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Proxy

## Requirements
- Set the `SERVER_URL` environment variable to the url of the proxy.
- Turn on websocket support in your proxy

&rarr; You won't be able to use your service via the plain local url as the websocket connection will fail.

If the SERVER_URL starts with
- https => Secured Websocket (wss)
- http => Unsecured Websocket (ws)

# Telegram

PodFetch can also send messages via Telegram if a new episode was downloaded.

To enable it you need to set the following variables:

| Variable | Description | example |
|----------------------|----------------------------------------------------------------|----------------------------------|
| TELEGRAM_BOT_TOKEN | The Bot token that you can acquire from Botfather with /newbot | asdj23:hsifuhi234klerlf...sadasd |
| TELEGRAM_BOT_CHAT_ID | The chat id of the chat where the bot should send the messages | 123456789 |
| TELEGRAM_API_ENABLED | If the telegram api should be enabled. | true |

You can acquire the Telegram Bot chat id with the following steps:
1. Write a message to the bot
2. Open the following url in your browser: https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/getUpdates
3. Search for the chat id in the response
4 changes: 4 additions & 0 deletions src/constants/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ pub const DEFAULT_SETTINGS: Setting = Setting {
};

pub const ERROR_LOGIN_MESSAGE: &str = "User either not found or password is incorrect";

pub const TELEGRAM_BOT_TOKEN: &str = "TELEGRAM_BOT_TOKEN";
pub const TELEGRAM_BOT_CHAT_ID: &str = "TELEGRAM_BOT_CHAT_ID";
pub const TELEGRAM_API_ENABLED: &str = "TELEGRAM_API_ENABLED";
26 changes: 21 additions & 5 deletions src/controllers/api_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,40 @@ use std::future;
use std::future::Ready;
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
use utoipa::{Modify, OpenApi};

use crate::controllers::podcast_controller::__path_find_all_podcasts;
use crate::controllers::podcast_controller::__path_find_podcast_by_id;
use crate::models::dto_models::PodcastFavorUpdateModel;
use crate::controllers::podcast_episode_controller::__path_find_all_podcast_episodes_of_podcast;
use crate::controllers::watch_time_controller::*;
use crate::controllers::podcast_controller::*;
use crate::controllers::notification_controller::*;
use crate::controllers::settings_controller::*;
use crate::models::settings::Setting;

#[derive(OpenApi)]
#[openapi(
paths(
find_podcast,
add_podcast,
import_podcasts_from_opml,
add_podcast_from_podindex,
find_podcast_by_id,
query_for_podcast,
download_podcast,
favorite_podcast,
get_favored_podcasts,
find_all_podcasts,
get_settings,
update_settings,
run_cleanup,
find_all_podcast_episodes_of_podcast,
log_watchtime,
get_last_watched,
get_unread_notifications,
dismiss_notifications,
get_watchtime
),
components(
schemas(Podcast, PodcastEpisode, ItunesModel, PodcastHistoryItem,
PodcastWatchedEpisodeModel, PodcastWatchedPostModel, PodCastAddModel)
schemas(Podcast, PodcastEpisode, ItunesModel, PodcastHistoryItem,PodcastFavorUpdateModel,
PodcastWatchedEpisodeModel, PodcastWatchedPostModel, PodCastAddModel, Setting)
),
tags(
(name = "podcasts", description = "Podcast management endpoints."),
Expand Down
12 changes: 12 additions & 0 deletions src/controllers/notification_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ use std::sync::Mutex;
use crate::mutex::LockResultExt;
use crate::service::notification_service::NotificationService;

#[utoipa::path(
context_path="/api/v1",
responses(
(status = 200, description = "Gets all unread notifications.")),
tag="notifications"
)]
#[get("/notifications/unread")]
pub async fn get_unread_notifications(db: Data<Mutex<NotificationService>>) -> impl Responder {
let notifications = db
Expand All @@ -17,6 +23,12 @@ pub struct NotificationId {
id: i32,
}

#[utoipa::path(
context_path="/api/v1",
responses(
(status = 200, description = "Dismisses a notification")),
tag="notifications"
)]
#[put("/notifications/dismiss")]
pub async fn dismiss_notifications(
id: web::Json<NotificationId>,
Expand Down
Loading

0 comments on commit 6537a92

Please sign in to comment.