-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Keycloak To Server #22
Conversation
server/course/router.go
Outdated
@@ -100,7 +102,7 @@ func createCourse(c *gin.Context) { | |||
return | |||
} | |||
|
|||
course, err := CreateCourse(c, newCourse) | |||
course, err := CreateCourse(c, newCourse, userID) | |||
if err != nil { | |||
handleError(c, http.StatusInternalServerError, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not return the plain error here. This may leak information to the enduser/attacker. This applies to most errors in this file here.
I would recommend to log
the error and return a more generic one
} | ||
|
||
roleString := fmt.Sprintf("%s-%s-Lecturer", createdCourse.Name, createdCourse.SemesterTag.String) | ||
err = CourseServiceSingleton.addUserToGroup(ctx, requesterID, roleString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens to the database object when this call fails? It should be rolled back, otherwise we have a database entry without its respective roles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is rolled back, as it happens within a transaction. If an error occurs, the function exits early and the transaction is never committed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I highly doubt that this applies to actions which are executed on the Keycloak Groups and roles. Which my comment was actually referring to
This PR shall be basis for discussion. I would really appreciate your comments @Mtze @robertjndw
The main idea:
My main question: Which roles to create?
We have two possibilities how to solve this
Key changes include:
Keycloak Integration:
server/course/router.go
. [1] [2]server/keycloak
package. [1] [2] [3] [4] [5]server/go.mod
. [1] [2] [3] [4]Service Layer:
CreateCourse
function inserver/course/service.go
. [1] [2]