feat: assign users to teams via OIDC claims #1393

Merged
konrad merged 93 commits from viehlieb/api:950_reworked_assign_teams_via_oidc into main 2024-03-02 08:47:12 +00:00
Showing only changes of commit 6d24e35671 - Show all commits

View File

@ -214,15 +214,12 @@ func HandleCallback(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
viehlieb marked this conversation as resolved Outdated

Please don't ignore the error.

Please don't ignore the error.
//TODO: fix this error check
// nil is no problem
//find old teams for user through oidc
oldOidcTeams, _ := models.FindAllOidcTeamIDsForUser(s, u.ID)
viehlieb marked this conversation as resolved Outdated

Please don't call this "Sign out". That's a different thing.

Please don't call this "Sign out". That's a different thing.
var oidcTeams []int64
if len(teamData) > 0 {
//find old teams for user through oidc
oldOidcTeams, _ := models.FindAllOidcTeamIDsForUser(s, u.ID)
// check if we have seen these teams before.
// find or create Teams and assign user as teammember.
var oidcTeams []int64
log.Debugf("TeamData is set %v", teamData)
teams, err := GetOrCreateTeamsByOIDCAndNames(s, teamData, u)
konrad marked this conversation as resolved Outdated

Doing this every time a user logs in probably has performance implications but that's a problem to care about when we'll hit it in the wild.

Doing this every time a user logs in probably has performance implications but that's a problem to care about when we'll hit it in the wild.

only if it has teamIDsToLeave, but yeah I agree.

The problem is more the oidc structure itself, that you "have" to check for changes "everytime" you sign in..

only if it has teamIDsToLeave, but yeah I agree. The problem is more the oidc structure itself, that you "have" to check for changes "everytime" you sign in..
if err != nil {
@ -243,8 +240,8 @@ func HandleCallback(c echo.Context) error {
for _, err := range errs {
log.Errorf("Found Error while signing out from teams %v", err)
}
SignOutFromOrDeleteTeamsByID(s, u, notIn(oldOidcTeams, oidcTeams))
}
SignOutFromOrDeleteTeamsByID(s, u, notIn(oldOidcTeams, oidcTeams))
err = s.Commit()
if err != nil {
_ = s.Rollback()