Skip to content

Latest commit

 

History

History
209 lines (168 loc) · 5.01 KB

File metadata and controls

209 lines (168 loc) · 5.01 KB

Provider SDK - One-Shot Password Framework

Status: Work in Progress

Overview

This SDK will enable developers to build One-Shot Password providers quickly and securely.

Language Support (Planned)

  • Node.js/TypeScript (Priority 1)
  • Python (Priority 1)
  • Go (Priority 2)
  • Java (Priority 2)
  • .NET/C# (Priority 3)

Core SDK Features (Ideas to Implement)

1. Authentication Module

// Conceptual API
const { OneShotProvider } = require('@oneshot/provider-sdk');

const provider = new OneShotProvider({
  providerId: 'your-provider-id',
  certificate: 'path/to/cert.pem',
  privateKey: 'path/to/key.pem'
});

// Starting point for auth flow
provider.authenticate(user, factors)
  .then(session => provider.deliverPassword(session, server))
  .catch(error => console.error('Auth failed:', error));
  1. Security Utilities (To Develop) Password encryption/decryption helpers Certificate management tools Secure key storage interfaces Token generation and validation

  2. MFA Integration (Initial Ideas)

// Pluggable MFA system concept
provider.addAuthFactor('biometric', BiometricAdapter);
provider.addAuthFactor('totp', TOTPAdapter);
provider.addAuthFactor('sms', SMSAdapter);
provider.addAuthFactor('hardware-key', FIDOAdapter);
  1. Server Communication (Starting Framework) Automatic retry with exponential backoff Circuit breaker pattern Request signing and verification Response validation

Example Provider Implementation (Skeleton)

class CustomProvider extends OneShotProvider {
  async validateUser(credentials) {
    // Custom user validation logic
  }
  
  async retrievePassword(userId, serverId) {
    // Secure password retrieval
  }
  
  async auditLog(event) {
    // Custom audit implementation
  }
}

Next Steps Define core interfaces Implement reference provider Create testing framework Build example applications

name=INTEGRATION_EXAMPLES.md
# Integration Examples - One-Shot Password Framework
**Status: Work in Progress**

## Overview
This document will provide code examples for integrating One-Shot Password into various platforms and frameworks.

## Web Application Integration (Ideas)

### Node.js/Express Example (Concept)
```javascript
const express = require('express');
const { OneShotServer } = require('@oneshot/server-sdk');

const app = express();
const oneshot = new OneShotServer({
  serverId: 'your-server-id',
  allowedProviders: ['provider1', 'provider2']
});

// Starting point for integration
app.post('/login/oneshot', async (req, res) => {
  try {
    const result = await oneshot.receivePassword(req.body);
    // Validate and create session
    res.json({ success: true, sessionId: result.session });
  } catch (error) {
    res.status(401).json({ error: 'Authentication failed' });
  }
});

Python/Django Integration (Initial Approach)

# views.py concept
from oneshot_framework import OneShotServer
from django.contrib.auth import login

class OneShotLoginView(View):
    def post(self, request):
        oneshot = OneShotServer(settings.ONESHOT_CONFIG)
        
        try:
            user_data = oneshot.validate_password(request.POST)
            user = authenticate(username=user_data['username'])
            login(request, user)
            return JsonResponse({'status': 'success'})
        except OneShotException as e:
            return JsonResponse({'error': str(e)}, status=401)

Frontend Integration (Ideas to Explore)

// React component concept
function OneShotLogin() {
  const [status, setStatus] = useState('idle');
  
  const initiateLogin = async () => {
    setStatus('authenticating');
    
    try {
      // SDK handles provider selection and MFA
      const result = await OneShotClient.authenticate({
        server: 'example.com',
        factors: ['biometric', 'device']
      });
      
      setStatus('success');
      window.location.href = result.redirectUrl;
    } catch (error) {
      setStatus('failed');
    }
  };
  
  return (
    <button onClick={initiateLogin}>
      Login with One-Shot Password
    </button>
  );
}

Mobile Integration (Starting Points) iOS/Swift Concept

import OneShotFramework

class LoginViewController: UIViewController {
    let oneshot = OneShotClient()
    
    @IBAction func loginTapped() {
        oneshot.authenticate(server: "example.com") { result in
            switch result {
            case .success(let session):
                // Navigate to authenticated view
            case .failure(let error):
                // Show error message
            }
        }
    }
}
class LoginActivity : AppCompatActivity() {
    private val oneshot = OneShotClient(this)
    
    fun onLoginClick() {
        oneshot.authenticate("example.com") { result ->
            when (result) {
                is Success -> navigateToHome()
                is Failure -> showError(result.error)
            }
        }
    }
}

Next Steps Complete working examples Add error handling patterns Create migration guides Build testing utilities Develop debugging tools