Add the auth pipeline for the Link API path.
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build was killed

This commit is contained in:
2023-08-10 20:06:27 +03:00
parent c793b46e53
commit aff4973ea8
7 changed files with 54 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
defmodule LinkShortenerWeb.Auth.Pipeline do
use Guardian.Plug.Pipeline, otp_app: :link_shortener,
module: LinkShortenerWeb.Auth.Guardian,
error_handler: LinkShortenerWeb.Auth.ErrorHandler
plug Guardian.Plug.VerifyHeader
plug Guardian.Plug.EnsureAuthenticated
plug Guardian.Plug.LoadResource
end
+12 -1
View File
@@ -17,6 +17,10 @@ defmodule LinkShortenerWeb.Router do
plug :accepts, ["json"]
end
pipeline :auth do
plug LinkShortenerWeb.Auth.Pipeline
end
scope "/", LinkShortenerWeb do
pipe_through :browser
@@ -29,12 +33,19 @@ defmodule LinkShortenerWeb.Router do
pipe_through :api
scope "/v1", Api.V1, as: :v1 do
resources "/links", LinkController
post "/users/signup", UserController, :create
post "/users/signin", UserController, :signin
end
end
scope "/api", LinkShortenerWeb do
pipe_through [:api, :auth]
scope "/v1", Api.V1, as: :v1 do
resources "/links", LinkController
end
end
# Enables LiveDashboard only for development
#
# If you want to use the LiveDashboard in production, you should put