-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install and configure Oban Web (#472)
* Install and configure LiveView * Add Oban Web mix dep * Configure required JS and mount oban in /admin * Add a resolver that limits Oban Web access to admins * Oban improvements - Only install in prod and dev - Upgrade to 2.10 (RC for now) - Use new resolver 'forbidden' feature - Remove no-longer-needed plugins - Only load ObanWeb code when installed * Do not add dev by default to oban_envs Otherwise this will not work for contributors by default. If OBAN_LICENSE_KEY env var is set, it's OK to add :dev too. Maybe :test as well? Signed-off-by: Gerhard Lazu <[email protected]> * Fix mix deps.get in dev & test I had to remove oban_met & oban_web from mix.lock, otherwise getting dependencies would fail with: ** (Mix) Unknown repository "oban", add new repositories with the `mix hex.repo add` task Signed-off-by: Gerhard Lazu <[email protected]> * Only build the production image if OBAN_LICENSE_KEY env var is set Otherwise it will fail - think about forks & PRs coming from forks. Signed-off-by: Gerhard Lazu <[email protected]> * Add Oban key fingerprint & license key to our CI/CD pipeline Signed-off-by: Gerhard Lazu <[email protected]> --------- Co-authored-by: Gerhard Lazu <[email protected]>
- Loading branch information
1 parent
ee0171f
commit 840bd9d
Showing
17 changed files
with
154 additions
and
36 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
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule ChangelogWeb.ObanWeb do | ||
@moduledoc """ | ||
Simple macro to conditionally load Oban.Web only if already loaded. This | ||
allows us to include it only in the production release and hence make it a lot | ||
easier on potential open source contributors, avoiding the problem of sharing | ||
the oban key and/or them hacking the code to get it working | ||
Thanks to the team at Glific for showing us the way on this. | ||
""" | ||
|
||
defmacro __using__(_) do | ||
if Code.ensure_loaded?(Oban.Web.Router) do | ||
defmodule Resolver do | ||
@behaviour Oban.Web.Resolver | ||
|
||
@impl true | ||
def resolve_user(conn) do | ||
conn.assigns.current_user | ||
end | ||
|
||
@impl true | ||
def resolve_access(user) do | ||
if Changelog.Policies.AdminsOnly.index(user) do | ||
:all | ||
else | ||
{:forbidden, "/in"} | ||
end | ||
end | ||
end | ||
|
||
quote do | ||
import Oban.Web.Router | ||
|
||
scope "/admin" do | ||
pipe_through [:browser, :admin] | ||
|
||
oban_dashboard("/oban", resolver: ChangelogWeb.ObanWeb.Resolver) | ||
end | ||
end | ||
end | ||
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
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
Oops, something went wrong.