irongate / integrationchief
Base functionality and helpers used for building for Chief Tools.
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.4
- laracasts/utilities: ^3.2
- laravel/framework: ^9.5
- laravel/helpers: ^1.5
- laravel/passport: ^10.3
- laravel/socialite: ^5.5
- mll-lab/graphql-php-scalars: ^5.4
- nuwave/lighthouse: ^5.45.1
- paragonie/certainty: ^2.8
- pusher/pusher-php-server: ^7.0
- sentry/sentry-laravel: ^2.11
- stayallive/laravel-eloquent-observable: ^1.0
- stayallive/laravel-eloquent-uuid: ^1.0
- stayallive/laravel-passport-memoized: ^1.0
- tuupola/base62: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: 3.8.*
This package is auto-updated.
Last update: 2022-07-25 19:15:48 UTC
README
Base functionality and helpers used for building for Chief Tools.
Configures
- (Socialite) authentication through Account Chief
- Laravel Passport for API access
- Sentry client
- Lighthouse GraphQL with base schema and scalars
- Session protected endpoint
/api/graphql/web - Session protected (GraphiQL) playground
/api/playground - OAuth (Passport) protected endpoint
/api/graphql
- Session protected endpoint
- Account pages to show profile information & preferences
- Basic API documentation & Passport personal access token management
- Redirects to Chief Tools homepage for
/contact,/privacy,/terms - Chief Tools webhook handler to be notified when a user account is closed or updated
- Health check queue job pinging
QUEUE_MONITOR_URLevery minute using the default queue (disabled whenQUEUE_MONITOR_URLis empty or unset) - Login event listener to update the
last_logincolumn on theuserstable
Provides
Middleware
IronGate\Chief\Middleware\AuthenticateChief
Validates a request comes from Chief Tools
Requiresservices.chief.webhook_secretconfiguration to be set to a random stringIronGate\Chief\Middleware\AutoAuthenticate
Uses both theapiandwebguard and sets the first that is authenticatedIronGate\Chief\Middleware\ForceSecure
Make sure the request is overhttps://IronGate\Chief\Middleware\MoveAccessTokenFromURLToHeader
Move the access token fromaccess_tokenGET paramater to theAuthorizationheaderIronGate\Chief\Middleware\SecurityHeaders
Adds a default set of security headers, can be configured by settingchief.response.securityheaders(array) in the app configIronGate\Chief\Middleware\TrustProxiesOnVapor
Configuresfideloper/proxyto be used on Laravel Vapor
Validation rules
IronGate\Chief\Rules\UUID
Valites the input value is a UUIDv4
Helpers
active($whitelist = null, $blacklist = null, $active = 'active', $inactive = '')
Get active state based on whitelist. Used to indicate active menu'stimezones(): array
Return an key-value list of all timezonesvalidate($fields, $rules): bool
Validate fields against rules. Examplevalidate($id, new \IronGate\Chief\Rules\UUID)latest_ca_bundle_file_path(): string
Get the path to the most up-to-date CA bundle file, uses Certainty under the hood
Installation
Start with requiring the package:
composer require irongate/chief
Publish the configuration files and optionally the migrations:
php artisan vendor:publish --tag=chief-config
# php artisan vendor:publish --tag=chief-migrations
Run the app migrations to create the users table:
php artisan migrate
Add the Chief service to the config/services.php:
<?php return [ 'chief' => [ 'client_id' => env('CHIEF_CLIENT_ID'), 'client_secret' => env('CHIEF_CLIENT_SECRET'), 'webhook_secret' => env('CHIEF_SECRET'), 'base_url' => env('CHIEF_BASE_URL', 'https://account.chief.app'), 'verify' => env('CHIEF_VERIFY', true), 'redirect' => '/login/callback', ], ];
That's all, you should be able to authenticate against Account Chief.
GraphQL API
You will need to create a routes/graphql/schema.graphql in your own project with the following contents:
#import ../../vendor/irongate/chief/routes/graphql/schema.graphql
Anything you want to add the the schema you can do thereafter, for example:
#import ../../vendor/irongate/chief/routes/graphql/schema.graphql #import ./types/*.graphql #import ./queries/*.graphql
Keep in mind that the User type is already provided so you will need to extend that if you want to append fields.
type OfType implements Entity { id: ID! } extend type User { relation: [OfType!]! @hasMany(type: "paginator") }