by moonboy
Internal tool (web app) with Google sign in and team management
import logging
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app
# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
def load(self):
Frequently Asked Questions
What are some business applications for this Flask-based internal tool template?
This Flask-based internal tool template is versatile and can be applied to various business scenarios:
- HR Management: Customize it for employee onboarding, performance tracking, or leave management.
- Project Management: Adapt it to track project progress, assign tasks, and manage resources.
- Sales CRM: Modify it to manage customer relationships, track leads, and monitor sales performance.
- Inventory Management: Adjust it to track stock levels, manage orders, and generate reports.
- IT Help Desk: Use it as a ticketing system for internal IT support requests.
The template's team management and Google sign-in features make it ideal for secure, role-based access control in these applications.
How does the team management feature benefit businesses using this internal tool template?
The team management feature in this Flask-based internal tool template offers several benefits:
- Access Control: It ensures that only authorized personnel can access the tool, enhancing security.
- Role-Based Permissions: Administrators can assign different roles (e.g., Admin, Manager, User) to control access to specific features.
- Easy Onboarding: New team members can be quickly added to the allow list or granted access via their email domain.
- Scalability: As the team grows, the tool can easily accommodate new users without compromising security.
- Audit Trail: It's easier to track who has access to the tool, aiding in compliance and security audits.
How can I customize the dashboard in this Flask-based internal tool template for my specific business needs?
To customize the dashboard for your business needs:
How can I add a new page to the Flask-based internal tool template?
To add a new page to the template, follow these steps:
How can I modify the authentication process in this Flask-based internal tool template to use a different OAuth provider?
To use a different OAuth provider, you'll need to modify the consolidated_auth_check
function in app_init.py
. Here's an example of how you might adapt it for GitHub OAuth:
```python from flask_github import GitHub
# Initialize GitHub OAuth github = GitHub(app)
@app.before_request def consolidated_auth_check(): if request.endpoint == 'static' or request.endpoint == 'logout': return None
if 'user_id' not in session:
return github.authorize()
# Check allowed list
if 'user' in session and 'email' in session['user']:
user_email = session['user']['email']
# ... (rest of the allow list checking logic)
@github.access_token_getter def token_getter(): return session.get('github_token')
@app.route('/github-callback') @github.authorized_handler def authorized(oauth_token): session['github_token'] = oauth_token github_user = github.get('/user') session['user'] = {'email': github_user['email']} return redirect(url_for('home_route')) ```
Remember to install the necessary package (flask-github
in this case) and update your OAuth credentials in the app configuration. This example demonstrates how the template's authentication system can be adapted to different OAuth providers while maintaining the core team management functionality.
Created: | Last Updated:
Here's a step-by-step guide for using the Flask-based Internal Tool Template with Google Sign-In and Team Management:
Introduction
This template provides a Flask-based internal tool with Google Sign-In and team management features. It's designed for creating secure internal applications where access is restricted to specific users or email domains.
Getting Started
- Click "Start with this Template" to begin using this template in the Lazy Builder interface.
Test the Application
- Click the "Test" button to deploy the application. This will launch the Lazy CLI and start the deployment process.
Using the Application
-
Once deployed, you'll receive a server link through the Lazy CLI. Open this link in your browser to access the application.
-
You'll be presented with a Google Sign-In page. Use your Google account to log in.
-
After logging in, you'll be redirected to the application's dashboard if your email is authorized. If not, you'll see an unauthorized access page.
Managing Team Access
The application provides two ways to manage access:
Allow List
- To add specific users to the allow list:
- Navigate to the "Company Admins" page
- Click "Add New Admin"
- Enter the email address of the user you want to grant access
Domain Access
- To allow access based on email domains:
- Go to the "Company Admins" page
- Click "Add New Email Ending"
- Enter the domain (e.g., "example.com") you want to allow
Blocking Users
- To block a user:
- Find the user in the "Company Admins" list
- Click the "Block" button next to their email
Customizing the Application
- To customize the application:
- Modify the HTML templates in the
templates
folder to change the UI - Update the routes in
routes.py
to add or modify functionality - Adjust the CSS in
static/css/styles.css
to change the appearance
Security Considerations
- The first user to log in becomes the super admin and cannot be deleted
- Regular admins can't delete themselves or the super admin
- Users from allowed domains are automatically added to the allow list upon first login
By following these steps, you'll have a functional internal tool with Google Sign-In and team management features. Remember to thoroughly test the access controls to ensure they meet your security requirements.
Template Benefits
-
Rapid Internal Tool Development: This template provides a ready-to-use foundation for building internal web applications, significantly reducing development time and effort for creating company-specific tools.
-
Secure Access Control: With built-in Google Sign-In and team management features, the template ensures that only authorized personnel can access the internal tool, enhancing security and data protection.
-
Flexible User Management: The allow list and email domain functionality offer granular control over user access, making it easy to manage team members' permissions as the organization grows or changes.
-
Professional UI/UX: The template includes a polished, responsive design with a sidebar navigation and custom styling, providing a professional look and feel that can be easily customized to match company branding.
-
Scalable Architecture: Built on Flask with SQLite database integration, the template offers a solid foundation that can be easily extended to accommodate more complex features and integrations as the internal tool evolves.