Overview
SGD-MCS implements a multi-layered security model using Google Workspace permissions, OAuth 2.0 scopes, and Apps Script execution policies.Access Control Levels
1. Google Sheets Permissions
The underlying Google Sheets database uses standard Google Drive sharing:Owner
Owner
Full control over the spreadsheet:
- Edit all data and structure
- Manage sharing settings
- Delete the database
- View version history
Editor
Editor
Can modify data but not sharing:
- Create, read, update, delete records
- Upload and organize files
- Cannot change sharing permissions
- Cannot delete the spreadsheet
Viewer
Viewer
Read-only access:
- View all data
- Export and download
- Cannot modify anything
No Access
No Access
Cannot see the spreadsheet:
- No visibility into data
- Cannot interact with the system
2. Google Drive Folder Permissions
TheROOT_FOLDER_ID folder contains all entity documents:
Set Permissions
- Editor: Can upload, organize, and delete files
- Viewer: Can only view and download files
- No access: Cannot see any documents
3. Apps Script Execution Mode
Configured inappsscript.json:
Determines whose permissions are used when running the script:
USER_DEPLOYING- Script runs with deployer’s permissions (recommended)- All users share the same data access level
- Deployer must have Editor access to Sheets and Drive
- Simpler security model
USER_ACCESSING- Script runs with each user’s own permissions- Users can only access data they personally have permission to see
- More complex to manage
- Better for multi-tenant scenarios
Controls who can access the web app:
ANYONE_ANONYMOUS- Anyone with the URL (no login required)- Completely public
- No authentication
- Use only for demos or internal networks
ANYONE- Anyone with a Google account (login required)- Must sign in with Google
- Email is captured for audit logs
- Recommended for production
DOMAIN- Only users in your Google Workspace organization- Must be part of your domain (e.g., @university.edu)
- Best security for organizational use
- Recommended for enterprise deployments
MYSELF- Only the deployer can access- For testing and development only
Recommended Production Configuration
For a secure production deployment:- Only organization members can access
- All actions are logged with user emails
- Consistent data access across users
- Deployer controls permissions via Sheet/Drive sharing
OAuth 2.0 Scopes
The script requests specific permissions from Google:Scope Breakdown
spreadsheets - Full Sheets Access
Scope:
https://www.googleapis.com/auth/spreadsheetsAllows:- Read all data from the database spreadsheet
- Create, update, delete student, faculty, thesis, and event records
- Increment ID counters in the Config sheet
- Write audit logs to Historial_Documentos
drive - Drive File Management
Scope:
https://www.googleapis.com/auth/driveAllows:- Create folders for entities (students, thesis, events)
- Upload documents and certificates
- Organize files into structured directories
- Move folders to trash on entity deletion
- List and search files
executeAs: USER_DEPLOYING, this is the deployer’s Drive)script.external_request - HTTP Requests
Scope:
https://www.googleapis.com/auth/script.external_requestAllows:- Make HTTP requests to external APIs
- Webhook integrations
- Third-party service connections
Authorization Flow
Initial Deployment
When first deploying the script, the deployer must authorize the requested OAuth scopes.
Consent Screen
Google displays a consent screen listing all requested permissions:
- View and manage spreadsheets
- View and manage files in Google Drive
- Connect to external services
User Authentication
The system captures user identity for audit logging:Authentication by Access Level
webapp.access | User Identity | Audit Trail |
|---|---|---|
ANYONE_ANONYMOUS | Empty string or “Anonymous” | ❌ Not available |
ANYONE | Google account email | ✅ Full email captured |
DOMAIN | Organization email | ✅ Full email captured |
MYSELF | Deployer email | ✅ Always known |
For proper audit trails, always use
ANYONE or DOMAIN access levels in production.Audit Logging
All entity and document operations are logged:Logged Actions
ENTITY_CREATE- New student, faculty, thesis, or event createdENTITY_UPDATE- Existing record modifiedUPLOAD_FILE- Document uploaded to entity folderSYNC_FOLDER- Drive folder created or linkedDELETE_ENTITY_FOLDER- Folder moved to trash
View Audit Logs
Open the Google Sheets database and navigate to the Historial_Documentos tab to view all logged actions.
Role-Based Access (Future Enhancement)
Currently, SGD-MCS uses Google Workspace permissions for access control. For finer-grained role-based access:Proposed Roles
Administrator
Administrator
Full system access:
- Manage all entities
- Configure system settings
- View audit logs
- Manage user permissions
Coordinator
Coordinator
Program management:
- Create/edit students, faculty, thesis
- Organize events
- Upload documents
- View reports
Faculty
Faculty
Limited access:
- View assigned students
- Update thesis progress
- Upload thesis documents
Student
Student
Self-service:
- View own profile
- View thesis information
- Download certificates
- Upload documents (with approval)
Implementation Approach
- Add a
Rolessheet to the database - Store user email → role mappings
- Implement authorization checks in API functions:
- Wrap sensitive operations with role checks
Security Best Practices
Use DOMAIN Access for Production
Use DOMAIN Access for Production
Restrict access to your organization:This prevents external users from accessing the system.
Secure the Deployer Account
Secure the Deployer Account
The deployer account has full access when using
USER_DEPLOYING:- Use a strong, unique password
- Enable 2-factor authentication
- Use a service account for production (advanced)
Regularly Review Sharing Settings
Regularly Review Sharing Settings
Periodically audit who has access to:
- The database spreadsheet
- The Drive root folder
- Individual entity folders
Monitor Audit Logs
Monitor Audit Logs
Review the Historial_Documentos sheet for:
- Unusual deletion patterns
- Bulk updates from unexpected users
- Access during off-hours
Backup Regularly
Backup Regularly
Create periodic backups:
- File → Make a copy (for spreadsheet)
- Copy the entire Drive folder structure
- Store backups in a secure location
Testing Permissions
Test as Different Users
Deploy the web app and access it from different Google accounts to verify access controls.
Troubleshooting
Authorization Required Error
Symptom: “Authorization required to perform that action”Cause: OAuth token expired or not grantedSolution:
- Open the Apps Script editor
- Run any function manually
- Complete the authorization flow
- Redeploy the web app
User Email Shows as Empty
Symptom: Audit logs show “Sistema/Anónimo” for all actionsCause: Using
ANYONE_ANONYMOUS access modeSolution: Change webapp.access to "ANYONE" or "DOMAIN" in appsscript.jsonPermission Denied When Uploading
Symptom: Users cannot upload files to entity foldersCause: Insufficient Drive permissionsSolution:
- Verify
ROOT_FOLDER_IDfolder has Editor sharing - Check that permissions cascade to subfolders
- Ensure
driveOAuth scope is authorized
Cannot Access from Organization
Symptom: Users in organization see “Access Denied”Cause: Script set to
MYSELF or not deployed correctlySolution:- Verify
webapp.accessis"DOMAIN" - Ensure deployment is set as “New deployment”, not “Test deployment”
- Share the correct deployment URL
Next Steps
Configuration
Configure database and system settings
Database Structure
Understand the database schema
Google Apps Script
Deploy and manage the backend