Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70545e0d
authored
Aug 29, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add iac-token attribute to user profile
parent
bc1ae921
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
3 deletions
+24
-3
circle/circle/settings/base.py
+9
-0
circle/dashboard/templates/dashboard/profile.html
+8
-0
circle/dashboard/views/user.py
+5
-1
circle/dashboard/views/vm.py
+2
-2
No files found.
circle/circle/settings/base.py
View file @
70545e0d
...
...
@@ -403,6 +403,15 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
########## END APP CONFIGURATION
REST_FRAMEWORK
=
{
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework.authentication.TokenAuthentication'
,
),
'DEFAULT_PERMISSION_CLASSES'
:
(
'rest_framework.permissions.IsAdminUser'
),
}
########## LOGGING CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
# A sample logging configuration. The only tangible logging
...
...
circle/dashboard/templates/dashboard/profile.html
View file @
70545e0d
...
...
@@ -42,6 +42,14 @@
{% trans "Email address" %}: {{ profile.email }}
{% endif %}
</p>
<p>
IAC-TOKEN:
{% if profile.is_superuser %}
<i>
{{ iac_token }}
</i>
{% else %}
for admin users only
{% endif %}
</p>
<p>
{% trans "Last login" %}:
<span
title=
"{{ profile.last_login }}"
>
{{ profile.last_login|arrowfilter:LANGUAGE_CODE}}
</span></p>
{% if request.user == profile %}
<p>
...
...
circle/dashboard/views/user.py
View file @
70545e0d
...
...
@@ -56,7 +56,7 @@ from ..models import Profile, GroupProfile, ConnectCommand
from
..tables
import
(
UserKeyListTable
,
ConnectCommandListTable
,
UserListTable
,
)
from
rest_framework.authtoken.models
import
Token
from
.util
import
saml_available
,
DeleteViewBase
,
LoginView
try
:
...
...
@@ -68,6 +68,8 @@ except NameError:
logger
=
logging
.
getLogger
(
__name__
)
def
set_session_expiry
(
request
,
user
):
if
user
.
is_superuser
:
messages
.
info
(
request
,
_
(
"You've logged in with an administrator "
...
...
@@ -387,6 +389,8 @@ class ProfileView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
context
[
'perm_email'
]
=
(
context
[
'perm_group_list'
]
or
self
.
request
.
user
==
user
)
context
[
'iac_token'
]
=
Token
.
objects
.
filter
(
user
=
user
)
.
get
()
# filter the virtual machine list
# if the logged in user is not superuser or not the user itself
# filter the list so only those virtual machines are shown that are
...
...
circle/dashboard/views/vm.py
View file @
70545e0d
...
...
@@ -90,11 +90,11 @@ logger = logging.getLogger(__name__)
from
rest_framework
import
status
from
rest_framework.decorators
import
api_view
,
authentication_classes
,
permission_classes
from
rest_framework.response
import
Response
from
rest_framework.authentication
import
SessionAuthentication
,
Basic
Authentication
from
rest_framework.authentication
import
Token
Authentication
from
rest_framework.permissions
import
IsAdminUser
@api_view
([
'GET'
])
@authentication_classes
([
SessionAuthentication
,
Basic
Authentication
])
@authentication_classes
([
Token
Authentication
])
@permission_classes
([
IsAdminUser
])
def
iac_vm_list
(
request
):
instances
=
Instance
.
objects
.
all
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment