mirror of
https://github.com/TakeusV1/flask_ipam.git
synced 2026-10-13 17:15:33 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1523fc977d | ||
|
|
969b7dac2f | ||
|
|
a19f59e9a2 | ||
|
|
6bae5cec91 | ||
|
|
275c575e90 | ||
|
|
2956b0abed | ||
|
|
5651121181 | ||
|
|
88c26c931c | ||
|
|
67094b541a | ||
|
|
e2380e6919 | ||
|
|
a5c9664bf1 | ||
|
|
bd40a774d7 | ||
|
|
47d9078473 | ||
|
|
55aaeae1da | ||
|
|
621b2b681a | ||
|
|
1c8ec0c159 | ||
|
|
7d60ce672b | ||
|
|
f3b6270504 | ||
|
|
eaa6499bd0 | ||
|
|
1464767d4e |
No files matched your search
+12
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.13.2-alpine3.21
|
||||||
|
WORKDIR /fipam
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
COPY app /fipam/app
|
||||||
|
COPY instance /fipam/instance
|
||||||
|
ENV APP_HOME=/fipam
|
||||||
|
ENV PYTHONPATH=${APP_HOME}
|
||||||
|
ENV PATH="$PATH:${APP_HOME}/.local/bin"
|
||||||
|
ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0:5000 --workers=2 --preload"
|
||||||
|
EXPOSE 5000
|
||||||
|
ENTRYPOINT ["gunicorn","app:create_app()"]
|
||||||
@@ -14,3 +14,10 @@ _(I'm not an experienced developer, just a tinkerer)_
|
|||||||
---
|
---
|
||||||
- Installation : [here](install.md)
|
- Installation : [here](install.md)
|
||||||
- Sources : [here](sources.md)
|
- Sources : [here](sources.md)
|
||||||
|
|
||||||
|
## Docker Compose
|
||||||
|
The Docker image has a built in admin account, **PLEASE CHANGE PASSWORD AFTER INITIAL LOG IN**
|
||||||
|
- Username: admin
|
||||||
|
- Password: _PleaseChangeMe_
|
||||||
|
<br>
|
||||||
|
Use docker-compose.yml file to deploy.
|
||||||
+8
-5
@@ -1,6 +1,8 @@
|
|||||||
##########################################################
|
##########################################################
|
||||||
############# CONFIGURATION FILE | Flask IPAM ############
|
############# CONFIGURATION FILE | Flask IPAM ############
|
||||||
|
|
||||||
|
import random, string
|
||||||
|
|
||||||
## Flask Server (For DEV)
|
## Flask Server (For DEV)
|
||||||
app_ip = '127.0.0.1'
|
app_ip = '127.0.0.1'
|
||||||
app_port = 80
|
app_port = 80
|
||||||
@@ -8,13 +10,14 @@ app_debug = True
|
|||||||
app_maintenance = False
|
app_maintenance = False
|
||||||
|
|
||||||
app_name = 'takeus-ipam'
|
app_name = 'takeus-ipam'
|
||||||
app_version = 'V1.2'
|
app_version = 'V1.3'
|
||||||
app_release_date = '02/2025'
|
app_release_date = '02/2025'
|
||||||
app_url = "http://127.0.0.1"
|
app_url = "http://0.0.0.0"
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
# openssl rand -hex 32
|
# replace SECRET_KEY with value from "openssl rand -hex 32" or similar for STATIC sessions
|
||||||
SECRET_KEY = 'change_me'
|
# With actual configuration, every application restart, user have to re-login...
|
||||||
|
SECRET_KEY = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(32))
|
||||||
# DB CONFIG
|
# DB CONFIG
|
||||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db'
|
SQLALCHEMY_DATABASE_URI = 'sqlite:///database.db'
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
@@ -22,4 +25,4 @@ class Configuration:
|
|||||||
# CK CONFIG
|
# CK CONFIG
|
||||||
SESSION_COOKIE_SECURE = False # SSL REQUIRED
|
SESSION_COOKIE_SECURE = False # SSL REQUIRED
|
||||||
SESSION_COOKIE_HTTPONLY = True
|
SESSION_COOKIE_HTTPONLY = True
|
||||||
SESSION_COOKIE_SAMESITE = 'Lax'
|
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||||
@@ -161,6 +161,7 @@ def allocation_delete(net_id,ipv4):
|
|||||||
db_alloc.description = None
|
db_alloc.description = None
|
||||||
db_alloc.is_dhcp = False
|
db_alloc.is_dhcp = False
|
||||||
db_alloc.is_gateway = False
|
db_alloc.is_gateway = False
|
||||||
|
db_alloc.is_decom = False
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("Allocation Removed", 'warning')
|
flash("Allocation Removed", 'warning')
|
||||||
return redirect(url_for('network.allocations',net_id=net_id,page=request.args.get('page', type=int)))
|
return redirect(url_for('network.allocations',net_id=net_id,page=request.args.get('page', type=int)))
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
name: Flask-IPAM
|
||||||
|
services:
|
||||||
|
flask-ipam:
|
||||||
|
image: ghcr.io/cafrays/flask_ipam:latest
|
||||||
|
container_name: flask-ipam
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
volumes:
|
||||||
|
- flask-ipam:/fipam/instance
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
flask-ipam:
|
||||||
+8
-2
@@ -2,10 +2,16 @@
|
|||||||
This documentation is very good, but needs a few changes to make it work (in our case) :
|
This documentation is very good, but needs a few changes to make it work (in our case) :
|
||||||
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04<br>
|
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04<br>
|
||||||
|
|
||||||
- You don't need to create `wsgi.py`, when asked, replace : `wsgi:app` with `'app:create_app()'` .
|
Before starting the app ensure to install pip packages in requirements.txt Referrenced [Section](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04#step-4-configuring-gunicorn)
|
||||||
|
- `pip install Flask-Login Flask-SQLAlchemy Flask-WTF mysql-connector-python SQLAlchemy cryptography`
|
||||||
|
- Update the configuration file under _app/\_config.py_.
|
||||||
|
- `app_ip = '127.0.0.1'` to `app_ip = '0.0.0.0'` for easy web access.
|
||||||
|
- Update **SECRET_KEY='CHANGE_ME'** variable, `openssl rand -hex 32` can be used to create a random key.
|
||||||
|
- You don't need to create or continue with the `wsgi.py` section. When asked, replace: `wsgi:app` with `'app:create_app()'` .
|
||||||
- EX : For starting APP with gunicorn : `gunicorn --bind 0.0.0.0:5000 'app:create_app()'`
|
- EX : For starting APP with gunicorn : `gunicorn --bind 0.0.0.0:5000 'app:create_app()'`
|
||||||
|
- For any troubleshooting, you can add `--preload` at the end of the command for verbose logging.
|
||||||
- In Service File, replace "ExecStart" line with :<br>
|
- In Service File, replace "ExecStart" line with :<br>
|
||||||
`ExecStart=/YOUR_ENV_LOCATION/bin/gunicorn --workers 1 --bind unix:fipam.sock -m 007 'app:create_app()'`<br>
|
`ExecStart=/YOUR_ENV_LOCATION/bin/gunicorn --workers 1 --bind 0.0.0.0:5000 -m 007 'app:create_app()'`<br>
|
||||||
_(Adjust the number of workers to your needs)_
|
_(Adjust the number of workers to your needs)_
|
||||||
- you must first run setup.py to create the admin user.<br>
|
- you must first run setup.py to create the admin user.<br>
|
||||||
_(it will create a second database in `./var/setup-instance`. It will have to be merged in the application database in `./var/app-instance`)_
|
_(it will create a second database in `./var/setup-instance`. It will have to be merged in the application database in `./var/app-instance`)_
|
||||||
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
|
wheel
|
||||||
|
gunicorn
|
||||||
Flask
|
Flask
|
||||||
Flask-Login
|
Flask-Login
|
||||||
Flask-SQLAlchemy
|
Flask-SQLAlchemy
|
||||||
Flask-WTF
|
Flask-WTF
|
||||||
mysql-connector-python
|
mysql-connector-python
|
||||||
SQLAlchemy
|
SQLAlchemy
|
||||||
cryptography
|
cryptography
|
||||||
@@ -10,9 +10,10 @@ db = SQLAlchemy(app)
|
|||||||
|
|
||||||
class User(db.Model):
|
class User(db.Model):
|
||||||
id = db.Column(db.Integer(),primary_key=True,unique=True)
|
id = db.Column(db.Integer(),primary_key=True,unique=True)
|
||||||
username = db.Column(db.String(16))
|
username = db.Column(db.String(16),unique=True)
|
||||||
password = db.Column(db.String(32),unique=True)
|
password = db.Column(db.String(32))
|
||||||
is_admin = db.Column(db.Boolean(),default=False)
|
is_admin = db.Column(db.Boolean(),default=False)
|
||||||
|
is_reado = db.Column(db.Boolean(),default=False)
|
||||||
dat_last = db.Column(db.DateTime())
|
dat_last = db.Column(db.DateTime())
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
@@ -21,7 +22,7 @@ with app.app_context():
|
|||||||
@app.route('/',methods=['GET','POST'])
|
@app.route('/',methods=['GET','POST'])
|
||||||
def setup():
|
def setup():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
db.session.add(User(username=request.form["username"],password=generate_password_hash(request.form["password"]),is_admin=True))
|
db.session.add(User(username=request.form["username"],password=generate_password_hash(request.form["password"]),is_admin=True,is_reado=False))
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return 'Done, you can delete setup.py'
|
return 'Done, you can delete setup.py'
|
||||||
return "<h1>admin user creation</h1><br><form method='post'><input name='username' placeholder='username'><br><input type='password' name='password' placeholder='password'><br><button type='submit'>submit</button></form>"
|
return "<h1>admin user creation</h1><br><form method='post'><input name='username' placeholder='username'><br><input type='password' name='password' placeholder='password'><br><button type='submit'>submit</button></form>"
|
||||||
|
|||||||
Reference in new issue
Block a user