# NFT-based Access Control Mediawiki Plugin Requirements
## 1. Overview
This document outlines the requirements for developing a Mediawiki plugin that implements NFT-based access control. The plugin will allow users to log in using Ethereum wallets and grant write access to the wiki based on NFT ownership.
## 2. Plugin Components
### 2.1 Authentication Module
- Implement a new authentication provider for Mediawiki
- Add support for Ethereum wallet-based authentication
### 2.2 NFT Verification Module
- Integrate with Alchemy's NFT ownership API
- Verify NFT ownership for authenticated users
### 2.3 User Interface Components
- Modify login page to include Ethereum login option
- Add profile page component for re-checking NFT access
### 2.4 Permission Management
- Implement custom permission handling based on NFT ownership
## 3. Detailed Requirements
### 3.1 Authentication Module
#### 3.1.1 Ethereum Login Option
- Add an "Log in with Ethereum" button to the login page
- Implement client-side code to interact with MetaMask and WalletConnect
- Create a server-side endpoint to handle Ethereum authentication requests
#### 3.1.2 Wallet Connection
- Use Web3.js or ethers.js library for wallet interactions
- Support MetaMask as the primary wallet option
- Implement WalletConnect as an alternative for other wallets
#### 3.1.3 Signature Verification
- Generate a unique message for the user to sign
- Verify the signature on the server-side to authenticate the user
### 3.2 NFT Verification Module
#### 3.2.1 Alchemy API Integration
- Set up an Alchemy account and obtain API credentials
- Implement server-side API calls to Alchemy's NFT ownership endpoint
#### 3.2.2 NFT Ownership Verification
- Define a list of valid NFT contract addresses
- Check if the user's wallet owns any NFTs from the defined list
- Store the verification result in the user's session or database
### 3.3 User Interface Components
#### 3.3.1 Login Page Modification
- Modify the Mediawiki login page template
- Add an "Log in with Ethereum" button alongside traditional login options
- Implement client-side JavaScript to handle wallet connection and signature requests
#### 3.3.2 Profile Page Addition
- Create a new section in the user's profile page
- Add a "Re-check NFT Access" button
- Implement client-side and server-side logic to perform NFT ownership re-verification
### 3.4 Permission Management
#### 3.4.1 Custom Permission Handler
- Create a new permission handler class that extends Mediawiki's default handler
- Implement logic to check NFT ownership status before granting write access
#### 3.4.2 Integration with Mediawiki
- Register the custom permission handler with Mediawiki's permission system
- Ensure the handler is called for all write actions on the wiki
## 4. Implementation Steps
1. Set up a development environment with a test Mediawiki installation
2. Create a new Mediawiki extension structure
3. Implement the Authentication Module
a. Develop client-side wallet connection logic
b. Create server-side authentication endpoints
c. Integrate with Mediawiki's authentication system
4. Implement the NFT Verification Module
a. Set up Alchemy API integration
b. Develop NFT ownership checking logic
5. Modify User Interface Components
a. Update login page template
b. Create profile page additions
6. Implement Permission Management
a. Develop custom permission handler
b. Integrate with Mediawiki's permission system
7. Test the plugin thoroughly
a. Unit tests for each module
b. Integration tests for the entire authentication flow
c. User acceptance testing
8. Document the plugin
a. Installation instructions
b. Configuration options
c. User guide
9. Package the plugin for distribution
## 5. Technical Stack
- PHP (compatible with our Mediawiki version)
- JavaScript
- Web3.js or ethers.js for Ethereum interactions
- Alchemy API for NFT verification
- MetaMask and WalletConnect for wallet connections
## 6. Security Considerations
- Implement proper signature verification to prevent authentication spoofing
- Secure storage of Alchemy API credentials
- Ensure all user inputs are properly sanitized and validated
## 7. Performance Considerations
- Cache NFT ownership results to reduce API calls
- Optimize database queries for permission checks
## 8. Future Enhancements
- Automated NFT ownership re-verification on a schedule (not important now)