Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
ff573ff6
Commit
ff573ff6
authored
7 years ago
by
Harsha Kethineni
Browse files
Options
Downloads
Patches
Plain Diff
subject and access_types params added
parent
8ada6b88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/handlers/reporthandler.py
+13
-1
13 additions, 1 deletion
api/handlers/reporthandler.py
with
13 additions
and
1 deletion
api/handlers/reporthandler.py
+
13
−
1
View file @
ff573ff6
...
...
@@ -437,6 +437,8 @@ class AccessLogReport(Report):
:end_date: ISO formatted timestamp
:uid: user id of the target user
:limit: number of records to return
:subject: subject code of session accessed
:access_types: list of access_types to filter logs
"""
super
(
AccessLogReport
,
self
).
__init__
(
params
)
...
...
@@ -445,6 +447,8 @@ class AccessLogReport(Report):
end_date
=
params
.
get
(
'
end_date
'
)
uid
=
params
.
get
(
'
user
'
)
limit
=
params
.
get
(
'
limit
'
,
100
)
subject
=
params
.
get
(
'
subject
'
,
None
)
access_types
=
params
.
getall
(
'
access_types
'
)
if
start_date
:
start_date
=
dateutil
.
parser
.
parse
(
start_date
)
...
...
@@ -460,12 +464,16 @@ class AccessLogReport(Report):
raise
APIReportParamsException
(
'
Limit must be an integer greater than 0.
'
)
if
limit
<
1
:
raise
APIReportParamsException
(
'
Limit must be an integer greater than 0.
'
)
for
access_type
in
access_types
:
if
access_type
not
in
[
'
user_login
'
,
'
view_container
'
]:
raise
APIReportParamsException
(
'
Not a valid access type
'
)
self
.
start_date
=
start_date
self
.
end_date
=
end_date
self
.
uid
=
uid
self
.
limit
=
limit
self
.
subject
=
subject
self
.
access_types
=
access_types
def
user_can_generate
(
self
,
uid
):
"""
...
...
@@ -487,6 +495,10 @@ class AccessLogReport(Report):
query
[
'
timestamp
'
][
'
$gte
'
]
=
self
.
start_date
if
self
.
end_date
:
query
[
'
timestamp
'
][
'
$lte
'
]
=
self
.
end_date
if
self
.
subject
:
query
[
'
context.subject.label
'
]
=
self
.
subject
if
self
.
access_types
:
query
[
'
access_type
'
]
=
{
'
$in
'
:
self
.
access_types
}
return
config
.
log_db
.
access_log
.
find
(
query
).
limit
(
self
.
limit
).
sort
(
'
timestamp
'
,
pymongo
.
DESCENDING
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment