Swiftpack.co - Package - nodes-vapor/admin-panel-provider

Admin Panel ✍️

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

Admin Panel makes it easy to setup and maintain admin features for your Vapor project. Here's a list of some of the top feautures that comes out of the box with this package:

  • UI Components: Admin Panel is built using AdminLTE, a highly battle-tested and maintained Control Panel Template. This means that you'll have access to features from AdminLTE through Leaf tags.
  • User System: This package come with a (admin panel) user system with roles built-in. The package also handles welcome emails and reset-password flows.
  • SSO Support: Built-in support for adding your own custom SSO provider.
  • Activities: Need to broadcast certain updates to the admin panel users? No problem, Admin Panel gives you some convenient functionality to manage an activity log.

📦 Installation

Install package using SPM

Update your Package.swift file:

.package(url: "https://github.com/nodes-vapor/admin-panel-provider.git", .upToNextMinor(from: "0.7.0")),
targets: [
        name: "App",
        dependencies: [

Next time you run e.g. vapor update Admin Panel will be installed.

Install resources

Copy the Resources and Public folders from this repo into your project. You can download the repo as a zip and then move the folders to the root of your project. Remember to check that you're not overwriting any files in your project.

If you are using Meta don't forget to add the following paths to the exceptPaths array within meta.json:

  • "/bower_components/*"
  • "/dist/*"
  • "/plugins/*"

🚀 Getting started

Add provider

In your Config+Setup.swift (or wherever you setup your providers), make sure to add the Admin Panel provider:

import AdminPanelProvider

// ...

private func setupProviders() throws {
    // ...
    try addProvider(AdminPanelProvider.Provider.self)

Also make sure that you add the Fluent provider if it hasn't been already:

try addProvider(FluentProvider.Provider.self)

Setup view renderer

This package relies heavily on the Leaf view renderer. For Admin Panel to work, please make sure that you have added the LeafProvider:

import LeafProvider

// ...

private func setupProviders() throws {
    // ...
    try addProvider(LeafProvider.Provider.self)

Make sure your project is using Leaf as the view renderer. You can set leaf as your renderer by setting the key view to the value leaf in your droplet.json. In case it's not given yet, just add it:

"//": "Choose which view renderer to use",
"//": "leaf: Vapor's Leaf renderer",
"view": "leaf",

Seed a user

If you haven't added a SSO provider, the next thing you need to do is to seed a user in order to be able to login into your new admin panel. To do this, add the seeder command to your commands array in your droplet.json:

"//": "Choose which commands this application can run",
"//": "prepare: Supplied by the Fluent provider. Prepares the database (configure in fluent.json)",
"commands": [

Now you have two ways of running the seeder. You either run the seeder in your terminal by:

vapor build; vapor run admin-panel:seeder

Or you temporarily edit the Run scheme in Xcode and add admin-panel:seeder under "Arguments Passed On Launch". This will run the seeder when you run the project. Run the project and remove the argument after the user has been seeded.

The user that will be created using the seeder will have the following credentials:

  • Email: admin@admin.com
  • Password: admin

Vapor & Fuzzy Array

Vapor has a Node.fuzzy array that's used for dynamically casting at runtime. If you're experiencing inconsistencies with rendering templates it's most likely because your fuzzy array is missing ViewData.self Ensure that you have added it to the array or that all of your models conform to JSON/Node. Example Node.fuzzy:

extension Config {
    public func setup() throws {
        // allow fuzzy conversions for these types
        // (add your own types here)
        Node.fuzzy = [JSON.self, Node.self, ViewData.self]

Custom Leaf tags

Admin Panel comes with a bunch of custom Leaf tags that help ease the burden of frontend development. Check out the full list here.


It's highly recommended that you add the CORS middleware to your project.

🔧 Configurations

Admin Panel can be configured by (adding or) modifying the adminpanel.json config file. Below is a breakdown of the available keys.

| Key | Example value | Required | Description | | -------------------| ---------------------------------------------------------------------------------------| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | name | My Tech Blog | No | This will be the title inside of the admin panel. | | baseUrl | http://mytechblog.com | No | This will be used to generate urls for the admin panel (e.g. when resetting a password). | | skin | green-light | No | The skin to use for the admin panel. The options will correspond to the available skins supported by AdminLTE. Please omit the skin- prefix when specifying the skin.| | email | {"fromName": "Admin Panel", "fromAddress": "admin@panel.com"} `| No | This will be used to configure the AdminPanel's mailer. |


Single sign-on can be a convenient way to offer users of your project to login into your admin panel.

🏆 Credits

This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Steffen.

📄 License

This package is open-sourced software licensed under the MIT license


Stars: 48

Used By

Total: 0


Version 0.7.6 - 2019-02-12 14:58:43


  • The Seeder type alias is now public as it was intended to be all along

Version 0.7.5 - 2018-08-07 19:49:28


  • Admin panel users created via Admin Panel backend can sign in now
  • Fixes checkboxes for sending credentials to the user and forcing a password reset
  • Fixes "email address already exists" issue when editing an admin panel user

Version 0.7.4 - 2018-06-20 12:25:53


  • Fix sidebar menu toggle
  • Fix default value in CheckboxGroup. Previously a null-value in the fieldset was interpreted as false
  • Add missing closing tag and remove duplicate import of adminlte.min.js in base.leaf


  • Update documentation to point to current major release (0.7.x)

Version 0.7.3 - 2018-06-19 13:50:20


  • Include name when sending emails


  • Shortened database table name for CustomUserAction in order to avoid MySQL too-long-foreign-key name on its relation with AdminPanelUser

Version 0.7.2 - 2018-06-08 11:28:12


  • Dategroup tag now accepts attributes as the last parameter
  • Dategroup tag displays any errors associated with the fieldset


  • error messages for DateGroup, TextGroup, and CheckboxGroup

Version 0.7.1 - 2018-05-31 12:10:07


  • made it possible to override the redirect path for ProtectMiddleware (or CustomUserProtectMiddleware) by supplying a closure like so:
ProtectMiddleware { user in
    "/path/to/user/\(user.id?.string ?? 0)/edit"

The same closure can be passed to PanelConfig so that it gets passed to the ProtectMiddleware by the Provider.

Version 0.7.0 - 2018-04-24 11:39:02


  • Made it possible to use a custom user type by conforming to AdminPanelUserType.

For example:

try addProvider(AdminPanelProvider.CustomUserProvider<Person>.self)

It is still possible to use the old API because there are type aliases for the new generic versions to the old and familiar types.

  • Requires Swift 4.1


  • Improved role checks on adding, editing, deleting users

Version 0.6.0 - 2018-04-23 11:48:22


  • upgraded frontend to use AdminLTE 2.4.3

Version 0.5.1 - 2018-04-16 11:30:08


  • Users are now redirected to the dashboard when visiting the login page while already being logged in.


  • Users are now correctly being persisted when logging in.

Version 0.5.0 - 2018-03-06 14:18:33


  • uses mailer configured in adminpanel.json instead of mailgun
  • does not needlessly depend on https://github.com/vapor/mysql-provider.git anymore

Version 0.4.3 - 2018-02-21 07:41:02

  • check email is unique when creating a new user
  • check email is unique when updating a user

Version 0.4.2 - 2018-02-19 10:32:37


• url to admin panel is now provided in welcome email

Version 0.4.1 - 2018-02-15 11:42:40


  • Admin panel users can now update profile info without having to reset their password afterwards

Version 0.4.0 - 2018-01-05 10:26:45


  • Make AdminPanelUser respect the key naming convention.

Version 0.3.0 - 2017-11-08 13:28:28


  • Updated Paginator version

Version 0.2.1 - 2017-10-23 09:17:57


  • An issue where a backend user with the "User" role could not reset their password.

Version 0.2.0 - 2017-10-23 07:59:10


  • Provider now takes in adminpanel.json properly as described in the readme (before it looked for admin.json instead).

Version 0.1.2 - 2017-10-05 08:00:43

  • add multi select support for SelectGroup Tag

Version 0.1.1 - 2017-10-02 23:26:59


  • Open up init for PanelConfigMiddleware

Version 0.1.0 - 2017-09-29 12:18:13

Close to feature-complete and should be stable to use - but use at your own risk.

Version 0.0.7 - 2017-09-13 15:10:28

Version 0.0.6 - 2017-09-01 11:53:40

Proper ref to Storage

Version 0.0.5 - 2017-09-01 10:53:19

Only require major version on Storage.

Version 0.0.4 - 2017-09-01 10:10:07

  • SSO moved out of package
  • Minor UI fixes

Version 0.0.3 - 2017-08-28 09:10:16

0.0.2 - 2017-08-17 10:18:38

Semi-stable development release - 2017-08-17 09:13:34

Development release - 2017-07-31 13:54:43

Development release