Download the PHP package dmstr/api-configuration-bundle without Composer

On this page you can find all versions of the php package dmstr/api-configuration-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api-configuration-bundle

dmstr/api-configuration-bundle

Manage external API connections as Doctrine entities.

Features

Changes per version are listed in CHANGELOG.md.

Requirements

PHP >= 8.5 and symfony/security-bundle with a firewall in front of /api/admin, see Access.

API clients

An extension implements ApiExtensionInterface (tagged automatically) and builds a client implementing ApiClientInterface, which holds only what every source supports. Optional capabilities are separate interfaces; implement those the source really supports, callers check instanceof:

Interface Methods
CustomerAwareApiClientInterface getCustomers()
TodoListAwareApiClientInterface getTodoLists()
ChangeProbeInterface hasChanges() — cheap, fail open; without it a source counts as always changed
UserAwareApiClientInterface getUsers()

authenticate() returns nothing and throws AuthenticationFailedException with the original exception as previous.

ApiClientFactory::create() validates the configuration against the extension's schema.json before calling createClient(), so extensions need no isset() checks of their own; an invalid configuration throws InvalidConfigurationException naming the field.

Health checks

ApiConfigurationHealthChecker serves the health route, app:api-configuration:health and application dashboards. For a type with a HealthProbeInterface (tagged automatically) it calls the probe with the decrypted configuration; otherwise it builds the client and calls getHealthInfo(). Types without a full client, such as schema-only connection types, only need a probe.

Security

Access

Every operation of the ApiConfiguration resource under /api/admin/api_configurations checks a permission attribute with is_granted(), because configJson holds the credentials for the upstream systems:

Permission Operations
apiconfig:read GET collection and item, GET /api/admin/api_configurations/{id}/health
apiconfig:write POST, PUT, PATCH, DELETE
apiconfig:authorize GET /api/admin/api_configurations/{id}/authorize, also the browser path (Accept: text/html, answered with a 303 redirect)

The constants are in Dmstr\ApiConfiguration\Security\ApiConfigurationPermissions (READ, WRITE, AUTHORIZE, all()). The bundle also registers the three attributes as za7_core.permission service tags (attribute permission), so applications that collect such tags can offer them for assignment; the bundle itself depends on nothing for this.

The bundle grants none of the permissions itself. A permission voter in the application maps its roles or users to the permissions; without one, every operation answers 403. Denied callers get 403 before any 404, anonymous callers 401 from the firewall. Credentials stay masked for every caller, and the hydra:operation list of an item only shows the operations the caller is allowed.

Migrating from 0.5

0.5 checked a fixed role; 0.6 checks the permissions above, so an application without a voter for them loses all access after the upgrade. A minimal voter granting all three permissions to an administrator role, with <your-admin-role> replaced by the role your application uses:

With autoconfiguration the voter is registered by itself. If the application already has a permission voter driven by a role-to-permission map, add the three attributes to the entry of <your-admin-role> instead. Clients that open the authorize URL in a browser need apiconfig:authorize as well; before 0.6 any authenticated caller got the redirect.

Secrets in configJson

A type marks its secret keys in its own schema.json with the standard JSON Schema annotation writeOnly:

Marked keys are found in nested objects, local $refs, allOf/anyOf/oneOf, if/then/else, array items and additionalProperties. The schema of a type is looked up by schema provider name, then by extension name, then by the type const of the registered schemas; for an unknown type the marked keys of all schemas apply, so a missing mapping over-masks instead of leaking.

For marked keys the bundle guarantees:

Encryption key

The key comes from dmstr/api-platform-utils-bundle. CredentialEncryption expects the 32 raw key bytes, the generated key is base64, so decode it in the configuration:

Without a usable key (missing, wrong length, not base64), storing or using a secret fails with Dmstr\ApiConfiguration\Security\SecretEncryptionException; nothing is stored in clear. Configurations without secrets keep working. Changing the key makes existing secrets unreadable.

Existing rows

Rows stored before encryption at rest hold their secrets in clear. Encrypt them once after the upgrade; the command is idempotent and leaves encrypted values alone, so it can also run on every deployment:

Rows that are updated through Doctrine are encrypted on the next flush anyway.

License

MIT © diemeisterei GmbH


All versions of api-configuration-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
symfony/framework-bundle Version ^7.0
api-platform/symfony Version ^4.0
doctrine/orm Version ^3.0
doctrine/doctrine-bundle Version ^2.8
dmstr/api-platform-utils-bundle Version *
dmstr/openapi-json-schema-bundle Version *
opis/json-schema Version ^2.3
symfony/expression-language Version ^7.0|^8.0
symfony/security-bundle Version ^7.0|^8.0
symfony/validator Version ^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dmstr/api-configuration-bundle contains the following files

Loading the files please wait ...