winglet/authclient

Client package for the Winglet Auth microservice.

Maintainers

Package info

bitbucket.org/eventteri/wingletauthclient

pkg:composer/winglet/authclient

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

v0.2 2026-06-22 15:17 UTC

This package is not auto-updated.

Last update: 2026-06-22 16:28:49 UTC


README

Packagist client package for the Winglet Auth microservice.

The package is intentionally light: request/response payloads are arrays so the client remains compatible with older PHP application code while still covering the current Auth API surface.

Install

composer require winglet/authclient

Usage

use Winglet\AuthClient\AuthClient;

$auth = AuthClient::fromBaseUrl(
    'http://auth-service',
    bearerToken: $serviceToken,
);

$effective = $auth->getEffectiveAuthorization(identityId: 123, tenantId: null);
$check = $auth->checkAuthorization(123, 'templify.admin');

Included endpoints

Authorization

  • getEffectiveAuthorization(int $identityId, ?int $tenantId = null)GET /authorization/effective
  • checkAuthorization(int $identityId, string $permissionCode, ?int $tenantId = null)POST /authorization/check
  • getGlobalAuthorizationRevision(int $identityId)GET /authorization/revisions/global/{identityId}
  • getTenantAuthorizationRevision(int $identityId, int $tenantId)GET /authorization/revisions/tenant/{identityId}/{tenantId}

Roles

  • listRoles(?string $scope = null, ?bool $includeDeprecated = null)
  • createRole(array $data)
  • getRole(int $id)
  • updateRole(int $id, array $data)
  • deleteRole(int $id)
  • addPermissionToRole(int $roleId, int $permissionId)
  • removePermissionFromRole(int $roleId, int $permissionId)

Permissions

  • listPermissions(?string $scope = null, ?bool $includeDeprecated = null)
  • createPermission(array $data)
  • getPermission(int $id)
  • updatePermission(int $id, array $data)
  • deletePermission(int $id)

Global assignments and grants

  • listGlobalRoleAssignments(?int $identityId = null, ?int $roleId = null, ?string $status = null)
  • createGlobalRoleAssignment(array $data)
  • getGlobalRoleAssignment(int $id)
  • updateGlobalRoleAssignment(int $id, array $data)
  • revokeGlobalRoleAssignment(int $id, ?string $reason = null)
  • listGlobalPermissionGrants(?int $identityId = null, ?int $permissionId = null, ?string $status = null)
  • createGlobalPermissionGrant(array $data)
  • getGlobalPermissionGrant(int $id)
  • updateGlobalPermissionGrant(int $id, array $data)
  • revokeGlobalPermissionGrant(int $id, ?string $reason = null)

Tenants and tenant-scoped assignments

  • listTenants(?string $code = null)
  • getTenant(int $id)
  • upsertTenant(int $id, array $data)
  • listTenantMemberships(?int $identityId = null, ?int $tenantId = null, ?string $status = null)
  • createTenantMembership(array $data)
  • getTenantMembership(int $id)
  • updateTenantMembership(int $id, array $data)
  • revokeTenantMembership(int $id, ?string $reason = null)
  • listTenantRoleAssignments(?int $tenantMembershipId = null, ?int $roleId = null, ?string $status = null)
  • createTenantRoleAssignment(array $data)
  • getTenantRoleAssignment(int $id)
  • updateTenantRoleAssignment(int $id, array $data)
  • revokeTenantRoleAssignment(int $id, ?string $reason = null)
  • listTenantPermissionGrants(?int $tenantMembershipId = null, ?int $permissionId = null, ?string $status = null)
  • createTenantPermissionGrant(array $data)
  • getTenantPermissionGrant(int $id)
  • updateTenantPermissionGrant(int $id, array $data)
  • revokeTenantPermissionGrant(int $id, ?string $reason = null)

Bootstrap

  • initializeBootstrap(int $rootIdentityId, ?string $reason = null)

Tests

composer install
composer test

The test suite uses a fake transport and does not require a running Auth service.

Payload examples

$auth->createPermission([
    'code' => 'templify.admin',
    'name' => 'Templify admin',
    'scope' => 'global',
]);

$auth->createRole([
    'code' => 'admin',
    'name' => 'Administrator',
    'scope' => 'global',
    'permissionIds' => [1, 2, 3],
]);

$auth->createGlobalRoleAssignment([
    'identityId' => 123,
    'roleId' => 1,
    'status' => 'active',
]);