An Igniter installer that patches an Ash Phoenix project with Bluetab defaults: Google OAuth login, admin user support, authenticated routing, and branded login UI.
Source: https://gitlab.bluetab.net/internalapps/tools/bluetab_phoenix
This installer is designed to run on top of a project generated with:
mix archive.install hex igniter_new --force
mix archive.install hex phx_new 1.8.3 --force
mix igniter.new my_app --with phx.new --install ash,ash_phoenix \
--install ash_postgres,ash_authentication \
--install ash_authentication_phoenix,ash_admin \
--install ash_oban,oban_web --install live_debugger,tidewave \
--install ash_ai,usage_rules --setup --yesAdd bluetab_phoenix as a dependency in your project's mix.exs:
def deps do
[
{:bluetab_phoenix, git: "https://github.com/Bluetab/bluetab_phoenix.git"}
]
endThen run:
mix deps.get
mix bluetab_phoenix.installThe installer will show a diff of all proposed changes and ask for confirmation before applying.
The installer applies the following changes to your project:
- Adds a
googlestrategy to the User resource (Accounts.User) - Adds a
register_with_googleaction with attribute mapping from Google user info - Adds user attributes:
email,given_name,family_name,picture,is_admin,confirmed_at - Adds a
unique_emailidentity - Configures
Secretsmodule withsecret_for/4clauses that readGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET, andGOOGLE_REDIRECT_URIfrom environment variables - Removes the default
add_onsblock (e.g.log_out_everywhere) from the User resource
- Replaces the default
ash_authentication_live_session :authenticated_routesblock with one that mountsHomeLiveat/ - Adds an
ash_authentication_live_session :admin_routesblock that mountsAdminLiveat/admin - Removes password-specific routes (
reset_route,confirm_route,magic_sign_in_route) - Removes the default
PageControllerand its templates (replaced byHomeLive)
- Adds an
is_adminboolean attribute (defaultfalse) to the User resource - Adds a
live_admin_requiredguard toLiveUserAuththat checksis_admin - Creates
HomeLive(authenticated) andAdminLive(admin-only) LiveView pages
- Relocates the AshAdmin dashboard route from
/adminto/admin/ashinside thedev_routesblock, so it doesn't conflict with the customAdminLivepage
- Updates the app layout header with navigation, theme toggle, conditional admin link, user email, and sign-out
- Configures
AuthOverrideswith Bluetab-branded login banner (light/dark images, app name) - Copies
bluetab_ibm_light.pngandbluetab_ibm_dark.pngtopriv/static/images/ - Adds
.envto.gitignore
-
Generate and run the database migration:
mix ash_postgres.generate_migrations --name google_login mix ash_postgres.migrate
-
Set the required environment variables (e.g. in a
.envfile):GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret GOOGLE_REDIRECT_URI=http://localhost:4000/auth/user/google/callback
-
To make a user an admin, set
is_admin: trueon their record.
The installer is safe to run multiple times. It checks for existing strategies, secrets, routes, and modules before making changes, so re-running it will not create duplicates.