Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
indietyp committed Apr 28, 2018
2 parents 65023d0 + 167c674 commit 3ec4b9c
Show file tree
Hide file tree
Showing 30 changed files with 355 additions and 178 deletions.
4 changes: 2 additions & 2 deletions ajax/views/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_perms(o, request, *args, **kwargs):

base = request.user.user_permissions if not request.user.is_superuser else Permission.objects
perms = base.all().order_by('content_type__model')
used = o.permissions if 'permissions' in o.__dict__ else o.user_permissions
used = o.permissions if 'permissions' in [f.name for f in o._meta.get_fields()] else o.user_permissions

return {'advanced': perms, 'base': modules, 'used': used.all()}

Expand All @@ -38,7 +38,7 @@ def group(request, page, *args, **kwargs):
obj = Group.objects.all()\
.annotate(perms=(Count('permissions') / perms) * 100)\
.order_by('perms')
return renderer(request, 'partials/setting/group.pug', obj, page)
return renderer(request, 'partials/setting/group.pug', obj, page, execute=get_perms)


@login_required(login_url='/login')
Expand Down
6 changes: 3 additions & 3 deletions api/lib/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

def search(query=''):
# Request
# GET http://steamcommunity.com/search/SearchCommunityAjax
# GET https://steamcommunity.com/search/SearchCommunityAjax

fake_session = uuid.uuid4().hex
try:
response = requests.get(
url="http://steamcommunity.com/search/SearchCommunityAjax",
url="https://steamcommunity.com/search/SearchCommunityAjax",
params={
"text": query,
"filter": "users",
Expand All @@ -28,7 +28,7 @@ def search(query=''):
"Pragma": "no-cache",
"Cookie": "sessionid=" + fake_session,
"Content-Type": "multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__",
"Referer": "http://steamcommunity.com/search/users/",
"Referer": "https://steamcommunity.com/search/users/",
},
files={
},
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions api/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
'country': {'type': 'string', 'nullable': True, 'default': None},

'server': {'type': 'uuid'},
'connected': {'type': 'boolean', 'dependencies': ['server'], 'nullable': True,
'default': None},
'connected': {'type': 'boolean', 'dependencies': ['server'], 'nullable': True},

'internal': {'type': 'boolean', 'default': False},
'permissions': {'type': 'list', 'schema': {'regex': '\w+\.\w+\_\w+'},
Expand All @@ -37,7 +36,11 @@
'POST': {'parameters': {'promotion': {'type': 'boolean', 'default': False},
'force': {'type': 'boolean', 'default': False},
'role': {'type': 'uuid', 'default': None, 'nullable': True, 'required': False},
'group': {'type': 'uuid', 'default': None, 'nullable': True, 'required': False}},
'group': {'type': 'integer', 'default': None, 'nullable': True, 'required': False},

'roles': {'type': 'list', 'default': None, 'nullable': True, 'schema': {'type': 'uuid'}},
'groups': {'type': 'list', 'default': None, 'nullable': True, 'schema': {'type': 'integer'}},
'permissions': {'type': 'list', 'schema': {'regex': '\w+\.\w+\_\w+'}, 'nullable': True, 'default': None}},
'permission': ['core.change_user']},
'DELETE': {'parameters': {'purge': {'type': 'boolean', 'default': False, 'required': False},
'reset': {'type': 'boolean', 'default': True, 'required': False},
Expand Down
1 change: 1 addition & 0 deletions api/views/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def list(request, validated={}, *args, **kwargs):

server = Server()
server.port = validated['port']
server.password = validated['password']
server.ip = ip
server.name = validated['name']
server.game = validated['game']
Expand Down
39 changes: 36 additions & 3 deletions api/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,45 @@ def detailed(request, u=None, s=None, validated={}, *args, **kwargs):

if validated['group'] is not None:
group = Group.objects.get(id=validated['group'])

if validated['promotion']:
user.groups.add(group)
else:
user.groups.remove(group)

if validated['roles']:
Membership.objects.filter(user=user).delete()

for role in validated['roles']:
group = ServerGroup.objects.get(id=role)
m = Membership()
m.user = user
m.role = group
m.save()

if validated['groups']:
groups = Group.objects.filter(id__in=validated['groups'])
user.groups.set(groups)

if validated['permissions'] is not None:
base = Permission.objects if request.user.is_superuser else request.user.user_permissions
exceptions = []
perms = []
for perm in validated['permissions']:
perm = perm.split('.')
p = base.filter(content_type__app_label=perm[0], codename=perm[1])

if not p:
exceptions.append('.'.join(perm))

perms.extend(p)

if exceptions:
return {'info': 'You are trying to assign permissions that either do not exist or are out of your scope.', 'affects': exceptions}, 403

user.user_permissions.set(perms)
user.save()

return ':+1:'

elif request.method == 'DELETE':
Expand All @@ -259,7 +293,7 @@ def detailed(request, u=None, s=None, validated={}, *args, **kwargs):
return 'user not using panel'

if validated['purge']:
if not user.is_superuser:
if user.is_superuser:
return 'superuser cannot be removed', 403

if request.user == user:
Expand All @@ -273,7 +307,7 @@ def detailed(request, u=None, s=None, validated={}, *args, **kwargs):
m = Membership.objects.get(user=user, role=validated['role'])
m.delete()
else:
if not user.is_superuser:
if user.is_superuser:
return 'superuser cannot be deactivated', 403

if request.user == user:
Expand All @@ -292,7 +326,6 @@ def detailed(request, u=None, s=None, validated={}, *args, **kwargs):
return '+1'


# TESTING
@csrf_exempt
@json_response
@authentication_required
Expand Down
91 changes: 10 additions & 81 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class UserAdmin(admin.ModelAdmin):
)


class MainframeAdmin(admin.ModelAdmin):
list_display = (
'domain',
'assigned',
'token',
)
list_filter = ()


class TokenAdmin(admin.ModelAdmin):
list_display = (
'id',
Expand All @@ -52,59 +61,6 @@ class TokenAdmin(admin.ModelAdmin):
date_hierarchy = 'created_at'


# class UserLogIPAdmin(admin.ModelAdmin):

# list_display = (
# 'id',
# 'created_at',
# 'updated_at',
# 'user',
# 'ip',
# 'connections',
# 'is_active',
# 'last_used',
# )
# list_filter = ('created_at', 'updated_at', 'user', 'is_active', 'last_used')
# date_hierarchy = 'created_at'


# class UserLogTimeAdmin(admin.ModelAdmin):

# list_display = (
# 'id',
# 'created_at',
# 'updated_at',
# 'user',
# 'server',
# 'connected',
# 'disconnected',
# )
# list_filter = (
# 'created_at',
# 'updated_at',
# 'user',
# 'server',
# 'connected',
# 'disconnected',
# )
# date_hierarchy = 'created_at'


# class UserLogUsernameAdmin(admin.ModelAdmin):

# list_display = (
# 'id',
# 'created_at',
# 'updated_at',
# 'user',
# 'username',
# 'connections',
# 'last_used',
# )
# list_filter = ('created_at', 'updated_at', 'user', 'last_used')
# date_hierarchy = 'created_at'


class ServerPermissionAdmin(admin.ModelAdmin):
list_display = (
'can_reservation',
Expand Down Expand Up @@ -194,22 +150,6 @@ class BanAdmin(admin.ModelAdmin):
date_hierarchy = 'created_at'


# class ChatAdmin(admin.ModelAdmin):

# list_display = (
# 'id',
# 'created_at',
# 'updated_at',
# 'user',
# 'ip',
# 'server',
# 'message',
# 'command',
# )
# list_filter = ('created_at', 'updated_at', 'user', 'server', 'command')
# date_hierarchy = 'created_at'


class MutegagAdmin(admin.ModelAdmin):
list_display = (
'id',
Expand All @@ -236,27 +176,16 @@ class MutegagAdmin(admin.ModelAdmin):
date_hierarchy = 'created_at'


# class LogAdmin(admin.ModelAdmin):

# list_display = ('id', 'created_at', 'updated_at', 'action', 'user')
# list_filter = ('created_at', 'updated_at', 'user')
# date_hierarchy = 'created_at'


def _register(model, admin_class):
admin.site.register(model, admin_class)


_register(models.Country, CountryAdmin)
_register(models.User, UserAdmin)
_register(models.Token, TokenAdmin)
# _register(models.UserLogIP, UserLogIPAdmin)
# _register(models.UserLogTime, UserLogTimeAdmin)
# _register(models.UserLogUsername, UserLogUsernameAdmin)
_register(models.ServerPermission, ServerPermissionAdmin)
_register(models.ServerGroup, ServerGroupAdmin)
_register(models.Server, ServerAdmin)
_register(models.Ban, BanAdmin)
# _register(models.Chat, ChatAdmin)
_register(models.Mutegag, MutegagAdmin)
# _register(models.Log, LogAdmin)
_register(models.Mainframe, MainframeAdmin)
2 changes: 2 additions & 0 deletions core/management/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def handle(self, *args, **options):
}
response = requests.put("https://{}/api/v1/instance/{}/report".format(settings.MAINFRAME, mainframe().id),
json=payload)

print(response.text)
identifier = response.json()['result']['id']

self.stdout.write(self.style.SUCCESS(
Expand Down
3 changes: 3 additions & 0 deletions core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def user_log_handler(sender, instance, raw, using, update_fields, **kwargs):
l.is_active = False
l.save()

if UserNamespace.objects.filter(user=instance, namespace=instance.namespace).count() > 1:
return

namespace, created = UserNamespace.objects.get_or_create(user=instance, namespace=instance.namespace)

try:
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

![color][image-2]

[1]: https://github.com/indietyp/hawthorne/
[1]: https://github.com/laevis/hawthorne/
[2]: getting-started#getting-started-with-hawthorne

[image-1]: images/logo.svg
Expand Down
14 changes: 14 additions & 0 deletions docs/changelog/v07.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@
* **Added:** Additional parameters for installation script
* **Fixed:** Login w/o location in steam *Thanks to Twiz for spotting that*
* **Fixed:** Toolchain `update` *Thanks to Czar for spotting that*

# v0.7.4 (2018-04-28)
* **Added:** German (100%), Swedish (80%), Dutch (60%), Chinese (46%) and Italian (18%) support. Help is appreciated! Let me know on Discord.
* **Added:** Ability to edit internal users and groups
* **Added:** Ability to delete internal users and groups
* **Added:** Parameters _roles and groups_ in `/api/v1/users/<uuid> - POST`
* **Fixed:** `hawthorne update` *Thanks to Hexah for testing*
* **Fixed:** Toolchain SELinux support *Thanks to Hexah for testing*
* **Fixed:** Login on some platforms *Thanks to Niceday for spotting that bug*
* **Fixed:** Adding a server *Thanks to Twiz, Niceday and Hexah for spotting that bug*
* **Fixed:** Steam based search *Thanks to Hexah for spotting that bug*
* **Updated:** docs and updated README
* **Updated:** moved hawthorne to the parent company laevis
* **Deprecated:** Parameters _role, group and promotion_ in `/api/v1/users/<uuid> - POST` (removed in **v0.9**)
10 changes: 6 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Hawthorne is an application that has multiple components, reaching from an API to a logging instance. To provide the best possible results in the installation process a shell script was created. To start the automated installation process execute the following command:

```bash
sh -c "$(curl -fsSL raw.githubusercontent.com/indietyp/hawthorne/master/cli/install.sh)"
sh -c "$(curl -fsSL raw.githubusercontent.com/laevis/hawthorne/master/cli/install.sh)"
```

!> In *v0.7.3* the `--nginx` flag was added, it installs nginx and configures it accordingly.
Expand Down Expand Up @@ -35,7 +35,9 @@ Example configurations are provided [here][5].

?> Please pay close attention to the comments provided. That guide you through the process of configuration.

**Note:** if nginx is installed over apt(-get), then the config has to be placed in `/etc/nginx/sites-avaiable` *The only thing you should change is the server_name* **Do not change any proxy_\* related things, this will break the configuration.**
!> **Note:** if nginx is installed over apt(-get), then the config has to be placed in `/etc/nginx/sites-avaiable` *The only thing you should change is the server_name* **Do not change any proxy_\* related things, this will break the configuration.**

!> **Note:** If you are using SELinux (_RHEL or centOS_) you need to enable that httpd is able to proxy connections. To do so please execute: `user=instance, namespace=instance.namespace`

If the recommended path of the automated installation has been chosen, a pre-configured script for your system would have been displayed.

Expand All @@ -62,11 +64,11 @@ If the recommended path of the automated installation has been chosen, a pre-con
4. Is your problem not listed? You can get in touch with me via [e-mail][8] or [Discord][9] Want to insult me? Please go ahead under `[email protected]` or `[email protected]`. Get creative. Let me be your guidance into an anger free lifestyle!


[1]: https://www.github.com/indietyp/hawthorne
[1]: https://www.github.com/laevis/hawthorne
[2]: mailto:[email protected]?subject=installation
[3]: toolchain.md "More Information"
[4]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
[5]: https://github.com/indietyp/hawthorne/tree/master/tools/configs
[5]: https://github.com/laevis/hawthorne/tree/master/cli/configs
[6]: https://stackoverflow.com/a/21627550/9077988
[7]: https://stackoverflow.com/a/16288118/9077988
[8]: mailto:[email protected]
Expand Down
2 changes: 1 addition & 1 deletion docs/services/Manual Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You are not worthy enough currently, please unlock the **ultimate power**, then
?> The packages are for apt are: _git python3 python3-dev python3-pip redis-server libxml2-dev libxslt1-dev libssl-dev libffi-dev git supervisor mysql-client build-essential curl nodejs_

# Setup
1. Clone project over GitHub directory: `https://github.com/indietyp/hawthorne`
1. Clone project over GitHub directory: `https://github.com/laevis/hawthorne`
2. Install python requirements over `pip` and _gunicorn_
3. Install pug over `npm`
4. Create `/var/log/hawthorne`
Expand Down
4 changes: 2 additions & 2 deletions docs/toolchain/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To execute the toolchain execute the following command. Please note that `<directory>` is the installation directory. If the automatic installation tool was used the directory is, if not else specified, `/hawthorne`

```bash
sh <directory>/tools/toolchain.sh
sh <directory>/cli/toolchain.sh
```

?> The automatic installation tool symlinks it to /usr/bin with the aliases **hawthorne** and **ht**
?> The automatic installation tool symlinks it to /usr/bin with the aliases **hawthorne** and **ht**
2 changes: 1 addition & 1 deletion interface/static/COMPILED/css/template.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion interface/static/COMPILED/css/template.css.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions interface/static/COMPILED/js/ajax.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ec4b9c

Please sign in to comment.