Skip to content

Commit

Permalink
Release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Aug 30, 2021
2 parents ba42c5e + 8d1ef19 commit eca8f32
Show file tree
Hide file tree
Showing 209 changed files with 8,372 additions and 3,668 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ POSTGRES_PASS=postgrespass
APP_PORT=80
API_PORT=80
HTTP_PROTOCOL=https
DOCKER_NETWORK="172.21.0.0/24"
DOCKER_NGINX_IP="172.21.0.20"
NATS_PORTS="4222:4222"
DOCKER_NETWORK=172.21.0.0/24
DOCKER_NGINX_IP=172.21.0.20
NATS_PORTS=4222:4222
2 changes: 1 addition & 1 deletion .devcontainer/api.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.2-slim
FROM python:3.9.6-slim

ENV TACTICAL_DIR /opt/tactical
ENV TACTICAL_READY_FILE ${TACTICAL_DIR}/tmp/tactical.ready
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ asyncio-nats-client
celery
channels
channels_redis
django-ipware
Django
django-cors-headers
django-rest-knox
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Tactical RMM is a remote monitoring & management tool for Windows computers, bui
It uses an [agent](https://github.com/wh1te909/rmmagent) written in golang and integrates with [MeshCentral](https://github.com/Ylianst/MeshCentral)

# [LIVE DEMO](https://rmm.tacticalrmm.io/)
Demo database resets every hour. Alot of features are disabled for obvious reasons due to the nature of this app.
Demo database resets every hour. A lot of features are disabled for obvious reasons due to the nature of this app.

### [Discord Chat](https://discord.gg/upGTkWp)

Expand All @@ -35,4 +35,4 @@ Demo database resets every hour. Alot of features are disabled for obvious reaso

## Installation / Backup / Restore / Usage

### Refer to the [documentation](https://wh1te909.github.io/tacticalrmm/)
### Refer to the [documentation](https://wh1te909.github.io/tacticalrmm/)
18 changes: 18 additions & 0 deletions api/tacticalrmm/accounts/migrations/0024_user_last_login_ip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.1 on 2021-07-20 20:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0023_user_is_installer_user'),
]

operations = [
migrations.AddField(
model_name='user',
name='last_login_ip',
field=models.GenericIPAddressField(blank=True, default=None, null=True),
),
]
33 changes: 33 additions & 0 deletions api/tacticalrmm/accounts/migrations/0025_auto_20210721_0424.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.1 on 2021-07-21 04:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0024_user_last_login_ip'),
]

operations = [
migrations.AddField(
model_name='role',
name='created_by',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='role',
name='created_time',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='role',
name='modified_by',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='role',
name='modified_time',
field=models.DateTimeField(auto_now=True, null=True),
),
]
10 changes: 9 additions & 1 deletion api/tacticalrmm/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class User(AbstractUser, BaseAuditModel):
loading_bar_color = models.CharField(max_length=255, default="red")
clear_search_when_switching = models.BooleanField(default=True)
is_installer_user = models.BooleanField(default=False)
last_login_ip = models.GenericIPAddressField(default=None, blank=True, null=True)

agent = models.OneToOneField(
"agents.Agent",
Expand All @@ -73,7 +74,7 @@ def serialize(user):
return UserSerializer(user).data


class Role(models.Model):
class Role(BaseAuditModel):
name = models.CharField(max_length=255, unique=True)
is_superuser = models.BooleanField(default=False)

Expand Down Expand Up @@ -140,6 +141,13 @@ class Role(models.Model):
def __str__(self):
return self.name

@staticmethod
def serialize(role):
# serializes the agent and returns json
from .serializers import RoleAuditSerializer

return RoleAuditSerializer(role).data

@staticmethod
def perms():
return [
Expand Down
7 changes: 7 additions & 0 deletions api/tacticalrmm/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Meta:
"email",
"is_active",
"last_login",
"last_login_ip",
"role",
]

Expand All @@ -57,3 +58,9 @@ class RoleSerializer(ModelSerializer):
class Meta:
model = Role
fields = "__all__"


class RoleAuditSerializer(ModelSerializer):
class Meta:
model = Role
fields = "__all__"
35 changes: 27 additions & 8 deletions api/tacticalrmm/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
from django.contrib.auth import login
from django.db import IntegrityError
from django.shortcuts import get_object_or_404
from ipware import get_client_ip
from knox.views import LoginView as KnoxLoginView
from logs.models import AuditLog
from rest_framework import status
from rest_framework.authtoken.serializers import AuthTokenSerializer
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

from logs.models import AuditLog
from tacticalrmm.utils import notify_error

from .models import User, Role
from .models import Role, User
from .permissions import AccountsPerms, RolesPerms
from .serializers import (
RoleSerializer,
TOTPSetupSerializer,
UserSerializer,
UserUISerializer,
RoleSerializer,
)


Expand All @@ -40,7 +40,9 @@ def post(self, request, format=None):
# check credentials
serializer = AuthTokenSerializer(data=request.data)
if not serializer.is_valid():
AuditLog.audit_user_failed_login(request.data["username"])
AuditLog.audit_user_failed_login(
request.data["username"], debug_info={"ip": request._client_ip}
)
return Response("bad credentials", status=status.HTTP_400_BAD_REQUEST)

user = serializer.validated_data["user"]
Expand Down Expand Up @@ -76,18 +78,35 @@ def post(self, request, format=None):

if valid:
login(request, user)
AuditLog.audit_user_login_successful(request.data["username"])

# save ip information
client_ip, is_routable = get_client_ip(request)
user.last_login_ip = client_ip
user.save()

AuditLog.audit_user_login_successful(
request.data["username"], debug_info={"ip": request._client_ip}
)
return super(LoginView, self).post(request, format=None)
else:
AuditLog.audit_user_failed_twofactor(request.data["username"])
AuditLog.audit_user_failed_twofactor(
request.data["username"], debug_info={"ip": request._client_ip}
)
return Response("bad credentials", status=status.HTTP_400_BAD_REQUEST)


class GetAddUsers(APIView):
permission_classes = [IsAuthenticated, AccountsPerms]

def get(self, request):
users = User.objects.filter(agent=None, is_installer_user=False)
search = request.GET.get("search", None)

if search:
users = User.objects.filter(agent=None, is_installer_user=False).filter(
username__icontains=search
)
else:
users = User.objects.filter(agent=None, is_installer_user=False)

return Response(UserSerializer(users, many=True).data)

Expand Down
3 changes: 2 additions & 1 deletion api/tacticalrmm/agents/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.contrib import admin

from .models import Agent, AgentCustomField, Note, RecoveryAction
from .models import Agent, AgentCustomField, Note, RecoveryAction, AgentHistory

admin.site.register(Agent)
admin.site.register(RecoveryAction)
admin.site.register(Note)
admin.site.register(AgentCustomField)
admin.site.register(AgentHistory)
27 changes: 27 additions & 0 deletions api/tacticalrmm/agents/migrations/0038_agenthistory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.1 on 2021-07-06 02:01

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('agents', '0037_auto_20210627_0014'),
]

operations = [
migrations.CreateModel(
name='AgentHistory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time', models.DateTimeField(auto_now_add=True)),
('type', models.CharField(choices=[('task_run', 'Task Run'), ('script_run', 'Script Run'), ('cmd_run', 'CMD Run')], default='cmd_run', max_length=50)),
('command', models.TextField(blank=True, null=True)),
('status', models.CharField(choices=[('success', 'Success'), ('failure', 'Failure')], default='success', max_length=50)),
('username', models.CharField(default='system', max_length=50)),
('results', models.TextField(blank=True, null=True)),
('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='history', to='agents.agent')),
],
),
]
25 changes: 25 additions & 0 deletions api/tacticalrmm/agents/migrations/0039_auto_20210714_0738.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.5 on 2021-07-14 07:38

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('scripts', '0008_script_guid'),
('agents', '0038_agenthistory'),
]

operations = [
migrations.AddField(
model_name='agenthistory',
name='script',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='history', to='scripts.script'),
),
migrations.AddField(
model_name='agenthistory',
name='script_results',
field=models.JSONField(blank=True, null=True),
),
]
Loading

0 comments on commit eca8f32

Please sign in to comment.