Skip to main content

Quick Start Guide

Get started with the SmarterServices IAM system in just a few steps. This guide will have you checking permissions in your application within minutes.

1. Choose Your Client Library

Select the appropriate client library for your platform:

Web Applications

@smarterservices/iam-client

Node.js Services

@smarterservices/iam-node

React Applications

@smarterservices/iam-react

Vue.js Applications

@smarterservices/iam-vue

2. Install the Library

# For web applications
npm install @smarterservices/iam-client

# For React applications
npm install @smarterservices/iam-react

# For Node.js services
npm install @smarterservices/iam-node

3. Initialize the Client

Web/JavaScript

import { IamClient } from '@smarterservices/iam-client';

const iam = new IamClient({
  apiUrl: 'https://iam.smarterservices.com',
  token: 'your-auth-token'
});

React

import { IamProvider } from '@smarterservices/iam-react';

function App() {
  return (
    <IamProvider
      apiUrl="https://iam.smarterservices.com"
      token={authToken}
    >
      <YourApp />
    </IamProvider>
  );
}

Node.js

const { IamService } = require('@smarterservices/iam-node');

const iam = new IamService({
  apiUrl: 'https://iam.smarterservices.com',
  serviceKey: 'your-service-key'
});

4. Check Permissions

Basic Permission Check

const canDelete = await iam.authorize(
  'sp:DeleteSession',
  'ssrn:ss:sp::578:session/ES123456'
);

if (canDelete) {
  // User has permission to delete the session
  deleteSession();
} else {
  // Show access denied message
  showAccessDenied();
}

React Component Protection

import { IamProtected } from '@smarterservices/iam-react';

function DeleteButton({ sessionId }) {
  return (
    <IamProtected 
      action="sp:DeleteSession" 
      resource={`ssrn:ss:sp::578:session/${sessionId}`}
    >
      <button onClick={handleDelete}>
        Delete Session
      </button>
    </IamProtected>
  );
}

Multiple Permission Checks

const permissions = await iam.authorizeMultiple([
  { action: 'sp:ReadSession', resource: 'ssrn:ss:sp::578:session/ES123456' },
  { action: 'sp:UpdateSession', resource: 'ssrn:ss:sp::578:session/ES123456' },
  { action: 'sp:DeleteSession', resource: 'ssrn:ss:sp::578:session/ES123456' }
]);

const { canRead, canUpdate, canDelete } = permissions;

5. Common Examples

Student Access

// Check if student can take an assessment
const canTakeAssessment = await iam.authorize(
  'sm:TakeAssessment',
  'ssrn:ss:sm::578:assessment/AS123456'
);

Instructor Access

// Check if instructor can view student results
const canViewResults = await iam.authorize(
  'sm:ViewResults',
  'ssrn:ss:sm::578:user/student123/results'
);

Proctor Access

// Check if proctor can monitor a session
const canMonitor = await iam.authorize(
  'sp:MonitorSession',
  'ssrn:ss:sp::578:session/ES123456'
);

Admin Access

// Check if user has admin privileges
const isAdmin = await iam.authorize(
  'platform:AdminAccess',
  'ssrn:ss:platform::578:admin'
);

6. Error Handling

Always handle errors gracefully:
try {
  const authorized = await iam.authorize(action, resource);
  
  if (authorized) {
    // Proceed with action
    performAction();
  } else {
    // Show user-friendly message
    showMessage('You do not have permission to perform this action');
  }
} catch (error) {
  if (error.code === 'NETWORK_ERROR') {
    showMessage('Unable to verify permissions. Please try again.');
  } else if (error.code === 'INVALID_TOKEN') {
    // Redirect to login
    redirectToLogin();
  } else {
    console.error('IAM error:', error);
    showMessage('Permission check failed');
  }
}

7. Configuration Options

const iam = new IamClient({
  apiUrl: 'https://iam.smarterservices.com',
  token: 'your-auth-token',
  cache: {
    enabled: true,
    ttl: 300, // 5 minutes
    maxSize: 1000
  }
});

Timeouts and Retries

const iam = new IamClient({
  apiUrl: 'https://iam.smarterservices.com',
  token: 'your-auth-token',
  timeout: 5000, // 5 seconds
  retries: 3
});

Next Steps

Now that you have IAM working in your application, explore these advanced topics:

📚 Learn Core Concepts

🎯 Advanced Features

🛠️ Implementation

  • Implementation Guide - Production deployment
  • Server middleware and framework integration
  • Performance optimization and monitoring

Common Patterns

Resource String Building

// Helper function for building resource strings
const buildSessionResource = (accountId, sessionId) => {
  return `ssrn:ss:sp::${accountId}:session/${sessionId}`;
};

// Usage
const resource = buildSessionResource('578', 'ES123456');
const canRead = await iam.authorize('sp:ReadSession', resource);

Permission Caching

// Cache permissions for better performance
const permissionCache = new Map();

async function checkCachedPermission(action, resource) {
  const key = `${action}:${resource}`;
  
  if (permissionCache.has(key)) {
    return permissionCache.get(key);
  }
  
  const result = await iam.authorize(action, resource);
  permissionCache.set(key, result);
  
  // Clear cache after 5 minutes
  setTimeout(() => permissionCache.delete(key), 300000);
  
  return result;
}

Bulk Permission Loading

// Load all permissions for a user session at once
async function loadUserPermissions(userId, accountId) {
  const permissions = await iam.authorizeMultiple([
    { action: 'sm:ReadUser', resource: `ssrn:ss:sm::${accountId}:user/${userId}` },
    { action: 'sm:UpdateUser', resource: `ssrn:ss:sm::${accountId}:user/${userId}` },
    { action: 'sm:TakeAssessment', resource: `ssrn:ss:sm::${accountId}:assessment/*` },
    { action: 'sp:ViewSessions', resource: `ssrn:ss:sp::${accountId}:session/*` }
  ]);
  
  return permissions;
}

Troubleshooting

Common Issues

  1. Invalid Token: Ensure your authentication token is valid and not expired
  2. Wrong Resource Format: Verify SSRN format: ssrn:service:partition::account:resource
  3. Network Issues: Check connectivity to IAM service
  4. Cache Issues: Clear cache if permissions seem outdated

Debug Mode

const iam = new IamClient({
  apiUrl: 'https://iam.smarterservices.com',
  token: 'your-auth-token',
  debug: true // Enable debug logging
});

Health Check

// Verify IAM service is available
const isHealthy = await iam.healthCheck();
if (!isHealthy) {
  console.warn('IAM service is unavailable');
}

🎉 Congratulations! You now have IAM integrated into your application. For more advanced features and production deployment guidance, continue with the Implementation Guide.