Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sdk Laravel Package

stormpath/sdk

Stormpath PHP SDK provides PHP access to Stormpath’s user management API: authentication and authorization, user profiles, hosted login/SSO, social and SAML logins, and API key authentication. Install via Composer (stormpath/sdk).

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require stormpath/sdk
    

    Add to config/services.php:

    'stormpath' => [
        'client_id' => env('STORMPATH_CLIENT_ID'),
        'client_secret' => env('STORMPATH_CLIENT_SECRET'),
        'tenant' => env('STORMPATH_TENANT'),
    ],
    
  2. First Use Case: Authentication Initialize the client in a service provider or controller:

    use Stormpath\Stormpath;
    
    $client = Stormpath::createClient(
        config('services.stormpath.client_id'),
        config('services.stormpath.client_secret')
    );
    $tenant = $client->getTenant(config('services.stormpath.tenant'));
    
  3. Key Entry Points

    • Stormpath::createClient() – Initialize the SDK.
    • $tenant->getAccountStore() – Access user accounts.
    • $tenant->getGroupStore() – Manage groups.
    • $tenant->getApplication() – Retrieve application settings.

Implementation Patterns

Common Workflows

User Authentication

// Login
$account = $tenant->getAccountStore()->authenticate(
    $email,
    $password,
    ['ipAddress' => request()->ip()]
);

// Register
$account = $tenant->getAccountStore()->createAccount([
    'email' => $email,
    'password' => $password,
    'givenName' => 'John',
    'surname' => 'Doe',
]);

Group Management

// Create a group
$group = $tenant->getGroupStore()->createGroup(['name' => 'Admins']);

// Add user to group
$account->addToGroup($group);

Application Integration

$application = $tenant->getApplication('your-app-href');
$application->setPasswordPolicy([
    'minPasswordLength' => 8,
    'requireNonAlphanumeric' => true,
]);

Laravel-Specific Patterns

  1. Middleware for Auth Create a middleware to handle Stormpath auth:

    class StormpathAuthenticate
    {
        public function handle($request, Closure $next)
        {
            $account = $request->user('stormpath');
            if (!$account) {
                return redirect()->route('login');
            }
            return $next($request);
        }
    }
    
  2. Service Provider Binding Bind the Stormpath client in AppServiceProvider:

    public function boot()
    {
        $this->app->singleton('stormpath.client', function ($app) {
            return Stormpath::createClient(
                config('services.stormpath.client_id'),
                config('services.stormpath.client_secret')
            );
        });
    }
    
  3. Custom User Model Extend Laravel’s User model to integrate Stormpath:

    class User extends Model implements Authenticatable
    {
        public function getAuthIdentifier()
        {
            return $this->email;
        }
    
        public static function findForPassport($identifier)
        {
            return self::where('email', $identifier)->first();
        }
    }
    

Gotchas and Tips

Pitfalls

  1. Deprecated API Stormpath’s migration to Okta means this SDK is archived. Use Okta’s PHP SDK (okta/okta-php) for new projects.

  2. Rate Limiting Stormpath enforces rate limits. Cache responses aggressively:

    $cacheKey = "stormpath_account_{$account->getHref()}";
    return Cache::remember($cacheKey, now()->addHours(1), function () use ($account) {
        return $account->getDetails();
    });
    
  3. HREF vs. ID Confusion Stormpath uses HREFs (e.g., /v1/accounts/123) instead of numeric IDs. Always use the full HREF when referencing entities.

  4. Password Hashing Stormpath handles hashing internally. Never hash passwords before sending to Stormpath.

Debugging

  • Enable Debug Mode
    Stormpath::setDebugMode(true); // Logs HTTP requests/responses
    
  • Check HTTP Status Codes Stormpath returns 404 for missing resources (e.g., invalid HREF). Validate HREFs before operations.

Extension Points

  1. Custom Account Attributes Extend the Account model to add custom fields:

    $account->setCustomData(['role' => 'admin']);
    $customData = $account->getCustomData();
    
  2. Webhook Listeners Use Stormpath’s webhooks for real-time events (e.g., account creation):

    $webhook = $tenant->getWebhookStore()->createWebhook([
        'url' => 'https://your-app.com/stormpath-webhook',
        'eventTypes' => ['ACCOUNT_CREATED'],
    ]);
    
  3. Bulk Operations Use pagination for large datasets:

    $accounts = $tenant->getAccountStore()->getAccounts();
    while ($accounts->hasNext()) {
        $accounts = $accounts->getNext();
        foreach ($accounts as $account) {
            // Process account
        }
    }
    

Configuration Quirks

  • Tenant Context Always specify the tenant when initializing:
    $tenant = $client->getTenant('your-tenant-href'); // Not just the name!
    
  • Environment Variables Store STORMPATH_CLIENT_ID, STORMPATH_CLIENT_SECRET, and STORMPATH_TENANT in .env:
    STORMPATH_TENANT=https://api.stormpath.com/v1/tenants/your-tenant-href
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calliostro/spotify-bundle
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle