Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LabraCORE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIP
Labrador
LabraCORE
Merge requests
!52
Resolve "Authorization endpoint"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "Authorization endpoint"
55-authorization-endpoint
into
development
Overview
0
Commits
2
Pipelines
6
Changes
5
Merged
Resolve "Authorization endpoint"
Sára Juhošová
requested to merge
55-authorization-endpoint
into
development
May 16, 2020
Overview
0
Commits
2
Pipelines
6
Changes
5
Closes
#55 (closed)
Edited
May 16, 2020
by
Chris Lemaire
0
0
Merge request reports
Compare
development
version 1
fb561b2a
May 16, 2020
development (base)
and
latest version
latest version
91f523b9
2 commits,
May 16, 2020
version 1
fb561b2a
2 commits,
May 16, 2020
5 files
+
303
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
src/main/java/nl/tudelft/labracore/controller/AuthorizationController.java
0 → 100644
+
88
−
0
View file @ 91f523b9
Edit in single-file editor
Open in Web IDE
/*
* Labracore - A connecting core service for Labrador products
* Copyright (C) 2020- Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
nl.tudelft.labracore.controller
;
import
javax.transaction.Transactional
;
import
nl.tudelft.labracore.model.RoleType
;
import
nl.tudelft.labracore.security.AuthorizationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@Transactional
@RestController
@RequestMapping
(
"/api/auth"
)
public
class
AuthorizationController
{
@Autowired
private
AuthorizationService
authService
;
/**
* Checks whether a person already has a role in the edition.
*
* @param personId the id of the person
* @param editionId the id of the edition
* @return true if the person already has a role in the edition
*/
@GetMapping
(
"/{personId}/role/{editionId}/edition"
)
public
Boolean
hasRoleInEdition
(
@PathVariable
Long
personId
,
@PathVariable
Long
editionId
)
{
return
authService
.
hasRoleInEdition
(
personId
,
editionId
);
}
/**
* Checks whether a person has a specific role in the edition.
*
* @param personId the id of the person
* @param editionId the id of the edition
* @param type the type of the role the person should have
* @return true if the person already has a role in the edition
*/
@GetMapping
(
"/{personId}/specific-role/{editionId}/edition"
)
public
Boolean
hasSpecificRoleInEdition
(
@PathVariable
Long
personId
,
@PathVariable
Long
editionId
,
@RequestParam
RoleType
type
)
{
return
authService
.
hasSpecificRoleInEdition
(
personId
,
editionId
,
type
);
}
/**
* Checks whether a person has the authority to create a course edition for a course.
*
* @param personId the id of the person
* @param courseId the id of the course
* @return true if the person is the manager of the course
*/
@GetMapping
(
"/{personId}/course-manager/{courseId}"
)
public
Boolean
isCourseManager
(
@PathVariable
Long
personId
,
@PathVariable
Long
courseId
)
{
return
authService
.
isCourseManager
(
personId
,
courseId
);
}
/**
* Checks whether a person can read course information. They must either a the manager of the course or
* have the role of teacher(-RO) in any of the course editions.
*
* @param personId the id of the person
* @param courseId the id of the course
* @return true if the person can read the data of a course
*/
@GetMapping
(
"/{personId}/course-read/{courseId}"
)
public
Boolean
canReadCoure
(
@PathVariable
Long
personId
,
@PathVariable
Long
courseId
)
{
return
authService
.
canReadCourse
(
personId
,
courseId
);
}
}
Loading