Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
examsAndAdmissions
Commits
a31038cb
Commit
a31038cb
authored
1 year ago
by
shishir suman
Browse files
Options
Download
Patches
Plain Diff
changes for uri check
parent
edea9692
uri_access_check
Response_fixes
auxillary_apis
bug_fix_question_paper_upload
development
fee_changes
fee_workflow
github/fork/ruksana2808/filter_bug_examCycle
instituteApis_shishir
1 merge request
!45
Fee workflow
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/tarento/upsmf/examsAndAdmissions/util/AccessTokenValidator.java
+22
-1
...o/upsmf/examsAndAdmissions/util/AccessTokenValidator.java
src/main/resources/application.properties
+3
-1
src/main/resources/application.properties
with
25 additions
and
2 deletions
+25
-2
src/main/java/com/tarento/upsmf/examsAndAdmissions/util/AccessTokenValidator.java
+
22
−
1
View file @
a31038cb
...
...
@@ -37,6 +37,12 @@ public class AccessTokenValidator {
@Value
(
"${admin.allowed.endpoints}"
)
private
String
adminAllowedEndpoints
;
@Value
(
"${institute.allowed.endpoints}"
)
private
String
instituteAllowedEndpoints
;
@Value
(
"${student.allowed.endpoints}"
)
private
String
studentAllowedEndpoints
;
@Value
(
"${user.roles}"
)
private
String
userRoles
;
...
...
@@ -76,13 +82,28 @@ public class AccessTokenValidator {
log
.
debug
(
"Role matched - {}"
,
roleMatches
);
if
(
roleMatches
)
{
log
.
info
(
"Role matched for userId - {}"
,
userId
);
boolean
isAdmin
=
roles
.
stream
().
anyMatch
(
x
->
"admin"
.
contains
(
x
.
toLowerCase
()));
boolean
isAdmin
=
roles
.
stream
().
anyMatch
(
x
->
"exams_admin"
.
equalsIgnoreCase
(
x
));
boolean
isSuperAdmin
=
roles
.
stream
().
anyMatch
(
x
->
"admin_superadmin"
.
equalsIgnoreCase
(
x
));
if
(
isAdmin
)
{
List
<
String
>
adminEndpoints
=
Arrays
.
asList
(
adminAllowedEndpoints
.
split
(
","
));
if
(!
adminEndpoints
.
contains
(
uri
))
{
return
Constants
.
Parameters
.
UNAUTHORIZED
;
}
}
boolean
isInstitute
=
roles
.
stream
().
anyMatch
(
x
->
"exams_institute"
.
equalsIgnoreCase
(
x
));
if
(
isInstitute
)
{
List
<
String
>
adminEndpoints
=
Arrays
.
asList
(
instituteAllowedEndpoints
.
split
(
","
));
if
(!
adminEndpoints
.
contains
(
uri
))
{
return
Constants
.
Parameters
.
UNAUTHORIZED
;
}
}
boolean
isStudent
=
roles
.
stream
().
anyMatch
(
x
->
"exams_student"
.
equalsIgnoreCase
(
x
.
toLowerCase
()));
if
(
isStudent
)
{
List
<
String
>
adminEndpoints
=
Arrays
.
asList
(
studentAllowedEndpoints
.
split
(
","
));
if
(!
adminEndpoints
.
contains
(
uri
))
{
return
Constants
.
Parameters
.
UNAUTHORIZED
;
}
}
return
userId
;
}
return
Constants
.
Parameters
.
UNAUTHORIZED
;
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/application.properties
+
3
−
1
View file @
a31038cb
...
...
@@ -109,4 +109,6 @@ spring.redis.port=6379
spring.redis.timeout
=
60000
user.redis.hash.key
=
USER
user.roles
=
admin_superadmin,exams_admin,exams_institute,exams_student
admin.allowed.endpoints
=
/payment
\ No newline at end of file
admin.allowed.endpoints
=
/payment
institute.allowed.endpoints
=
student.allowed.endpoints
=
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets