-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33765a2
commit ab75c1d
Showing
9 changed files
with
149 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<video id="video" phx-hook="episode" poster={MediaServerWeb.Repositories.Episodes.get_background(@episode)} controlsList="nodownload" controls autoplay> | ||
<source src={Routes.stream_episode_path(@socket, :show, @episode["id"])} type="video/mp4"> | ||
<source src={Routes.stream_episode_path(@socket, :show, @episode["id"], token: Phoenix.Token.sign(MediaServerWeb.Endpoint, "user auth", @current_user.id))} type="video/mp4"> | ||
</video> |
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,3 +1,3 @@ | ||
<video id="video" phx-hook="movie" poster={MediaServerWeb.Repositories.Movies.get_background(@movie)} controlsList="nodownload" controls autoplay> | ||
<source src={Routes.stream_movie_path(@socket, :show, @movie["id"])} type="video/mp4"> | ||
<source src={Routes.stream_movie_path(@socket, :show, @movie["id"], token: Phoenix.Token.sign(MediaServerWeb.Endpoint, "user auth", @current_user.id))} type="video/mp4"> | ||
</video> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule MediaServerWeb.Plugs.VerifyToken do | ||
import Plug.Conn | ||
|
||
def init(default), do: default | ||
|
||
def call(%Plug.Conn{params: %{"token" => token}} = conn, _default) do | ||
case Phoenix.Token.verify(conn, "user auth", token, max_age: 86400) do | ||
{:ok, _user_id} -> conn | ||
{:error, :invalid} -> conn |> resp(403, "Forbidden") |> halt | ||
{:error, :expired} -> conn |> resp(403, "Forbidden") |> halt | ||
end | ||
end | ||
|
||
def call(conn, _default) do | ||
conn |> resp(403, "Forbidden") |> halt | ||
end | ||
end |
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