Download the PHP package spkm/clear-pass without Composer

On this page you can find all versions of the php package spkm/clear-pass. 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 clear-pass

Banner

Tests Latest version PHP version

A Laravel package for the Aruba ClearPass REST API, built with Saloon. It has a typed model, a request and an Eloquent-style query builder for every service in ClearPass's API Explorer, grouped as the explorer groups them: apiOperations(), certificateAuthority(), endpointVisibility(), enforcementProfile(), globalServerConfiguration(), guestActions(), guestConfiguration(), identities(), insight(), integrations(), localServerConfiguration(), logs(), platformCertificates(), policyElements(), sessionControl() and toolsAndUtilities().

Requirements

Installation

The install command publishes config/clearpass.php. Set the server and the client in .env:

Upgrading from version 1

Code written for version 1 keeps working, apart from the PHP and Laravel minimums above and the config file's publish tag (clearpass-config, published by clearpass:install). The request classes version 1 shipped stay where they were, taking the same arguments, and DTOs\GuestUser still describes a guest account to create or change, so ClearPass::send(new CreateGuestUserRequest($guestUser)) and ClearPass::send(new GetGuestUserByUsernameRequest($username))->json() do what they did. Those classes are deprecated in favour of the ones under Requests\Identities\GuestUser, Requests\PolicyElements\Role and Requests\ApiOperations, and of the resources below, which return models rather than arrays:

Version 1 Now
Requests\Identities\GetGuestUsersRequest Requests\Identities\GuestUser\GetGuestUsersRequest, or ClearPass::identities()->guestUsers()->get()
Requests\Identities\GetGuestUserByUsernameRequest Requests\Identities\GuestUser\GetGuestUserByUsernameRequest, or guestUsers()->findByUsername()
Requests\Identities\CreateGuestUserRequest(DTOs\GuestUser) Requests\Identities\GuestUser\CreateGuestUserRequest(array|JsonSerializable), or guestUsers()->create()
the other Requests\Identities\*GuestUser* classes the same names under Requests\Identities\GuestUser, taking the account's id or username first
Requests\PolicyElements\Get{Roles,Role,RoleByName}Request the same names under Requests\PolicyElements\Role, or ClearPass::policyElements()->roles()
Requests\ApiOperations\GetToken{Info,Privileges}Request Requests\ApiOperations\TokenInfo\GetTokenInfoRequest and TokenPrivileges\GetTokenPrivilegesRequest
DTOs\GuestUser Data\Identities\GuestUser, the model guest account requests return and accept

Other changes:

Usage

Two ways to call ClearPass

Resources give an Eloquent-style builder for each collection, reached from the API group it belongs to. They return models and throw a ClearPassApiException when ClearPass answers with an error:

Requests are plain Saloon, for when you want the response itself:

ClearPass::get(), post(), put(), patch() and delete() send any path, and ClearPass::from('/some-path') gives a builder over a collection the package has no resource for, returning arrays. Every resource, request and model is listed in ENDPOINTS.md.

Resources

Each API group is a method on the facade, and each service a method on the group. A collection gives a builder; a setting ClearPass keeps one of (such as guestConfiguration()->guestManager()) gives get(), update(), replace() and, where ClearPass allows, create() and delete(); an action ClearPass performs (such as guestActions()->sendSmsReceipt($guestId, $body)) is a method on the group.

Query options an operation documents, such as change_of_authorization on guest and device writes or async on session actions, go in the last array argument.

The query builder

ClearPass filters, sorts and pages in the query string, and the builder writes those parameters for you: filter as ClearPass's JSON filter expression, sort as +field or -field, offset and limit.

Builder ClearPass
where($f, $value), where($f, '=', $value) {"f": value}
whereNot($f, $value), where($f, '!=', $value) {"f": {"$ne": value}}
where($f, '>' / '>=' / '<' / '<=', $value) $gt $gte $lt $lte
whereIn, whereNotIn $in, $nin
whereBetween($f, [$from, $to]) {"f": {"$gte": from, "$lte": to}}
whereContains($f, $text) $contains
whereRegex($f, $pattern, caseInsensitive: true) $regex with "$options": "i"
whereNull, whereNotNull {"$exists": false}, {"$exists": true}
orWhere($f, ...), orWhere(fn ($query) => ...) {"$or": [...]}
whereNot(fn ($query) => ...) {"$not": {...}}

Conditions on different fields, and different operators on one field, are ANDed in one object; anything ClearPass cannot read in one object is wrapped in {"$and": [...]}. Dates can be strings or DateTimeInterface objects and are written as the service's records carry them: Unix timestamps for guest accounts and devices, ISO 8601 elsewhere.

Fetching:

Call Returns
get() a Collection of models: one page, as many as limit() asked for (ClearPass's default is 25)
all() a Collection of every matching record, fetched a page at a time
first() one model or null, in sort order
count(), exists() how many records match (asks ClearPass for calculate_count)
find($id), findOrFail($id) one model by id, null (or NotFoundException) when there is none
findBy…($key) one model by the other key the service documents: findByName(), findByUsername(), findByMacAddress(), …
lazy($perPage), cursor() a LazyCollection that fetches each page as the loop reaches it
paginate($perPage) a Saloon paginator, for stepping through pages yourself
toRequest(), toArray(), toFilter() the request, the query parameters or the filter the builder would send

Models

Every record is a readonly class under spkm\ClearPass\Data\{Group} whose properties carry ClearPass's own names and types: integer as int, number as float, boolean as bool, string as string (with the allowed values in the property's comment where ClearPass lists them), date-time as CarbonImmutable, objects as arrays and lists of records as Collections of their model, all nullable. Anything ClearPass adds later is ignored on the way in; toArray() and json_encode() give the record back in ClearPass's keys, leaving out what is null.

Guest accounts and devices carry custom fields at the top level of the record; the model keeps them in $extra and sends them back the same way. The few field names that aren't PHP identifiers (DisableTLS1.0 and the like) are properties with underscores (DisableTLS1_0) and serialise under ClearPass's name.

Writing

A resource creates, updates (PATCH), replaces (PUT) and deletes where ClearPass documents it, taking an array of ClearPass's field names or a model:

create() returns the record ClearPass stored; update() and replace() return the record as changed, or null when ClearPass answers that nothing changed (204 or 304). A resource without a documented write throws a LogicException rather than guessing at a path.

Errors

A request that ClearPass answers with an error throws a spkm\ClearPass\ClearPassApiException (a Saloon RequestException) from dto() and from every resource method; ClearPass::send() gives you the response to inspect instead.

ClearPass's answer Exception
400, 406, 415 InvalidRequestException
401, 403 (the client's profile doesn't allow the operation) UnauthorizedException
404 NotFoundException
422 (the record was rejected) ValidationException, an InvalidRequestException
408, 5xx, or a success whose body isn't JSON ServerErrorException

The message says what happened (ClearPass responded 422 to POST /api/guest: Unprocessable Entity; Validation failed; username: Value is required): ClearPass's title and detail, then each field it rejected. title(), detail() and validationMessages() (field => [rule => message]) give the parts.

Several servers

Add other servers under connections in config/clearpass.php and reach them with ClearPass::connection('name'), which gives a connector with the same resources and methods as the facade.

Caching, timeouts and retries

Testing

The suite fakes ClearPass with Saloon's MockClient; nothing reaches a real server.

Contributing

Run composer install once to enable the pre-commit hook, which runs Pint, PHPStan and the tests.

Security

If you discover a security issue, please don't open a public issue. Report it privately through GitHub instead. See SECURITY.md for details.

Credits

Licence

MIT.


All versions of clear-pass with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
illuminate/cache Version ^12.39||^13.0
illuminate/collections Version ^12.39||^13.0
illuminate/contracts Version ^12.39||^13.0
illuminate/encryption Version ^12.39||^13.0
illuminate/support Version ^12.39||^13.0
saloonphp/cache-plugin Version ^3.0
saloonphp/laravel-plugin Version ^4.0||^5.0
saloonphp/pagination-plugin Version ^2.0
saloonphp/saloon Version ^4.4
spatie/laravel-package-tools Version ^1.19
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 spkm/clear-pass contains the following files

Loading the files please wait ...