This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
forked from raystack/dex
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(warden): added API for wardenTeamList and updateGroupByShieldMet…
…aData (#72) * feat(warden): added API for teamList * chore: format * feat(warden): updated getTeam call * feat(warden): updated error handling * feat(warden): refactor * chore: format * chore: formatting * feat(warden): updateGroupMetaData with warden team * chore: refactor * chore: lint resolved * test(warden): added test for teamList, updateGroup * test(warden) : more test added * feat(warden): test, error refactored * chore: format and lint resolved * feat(warden): added warden host as a config * feat(warden) : added warden client * feat(warden): replaced warden route by iam * feat(warden): updated tests * feat(warden): updated test names * feat(warden): updated unit test timezone * feat(warden): added team-name & product-group-name * feat(warden): route updated * feat(warden): updated errors * feat(warden): error handled * feat(warden): error handling * feat(warden): error updated. * feat(warden): client error handling updated --------- Co-authored-by: Sudheer Pal <[email protected]>
- Loading branch information
1 parent
89f65a0
commit 8f39ef9
Showing
20 changed files
with
4,792 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule dex
added at
786037
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package iam | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/go-chi/chi/v5" | ||
|
||
"github.com/goto/dex/internal/server/reqctx" | ||
"github.com/goto/dex/internal/server/utils" | ||
) | ||
|
||
type handler struct { | ||
service *Service | ||
} | ||
|
||
func NewHandler(service *Service) *handler { | ||
return &handler{service: service} | ||
} | ||
|
||
func (h *handler) listUserWardenTeams(w http.ResponseWriter, r *http.Request) { | ||
reqCtx := reqctx.From(r.Context()) | ||
const errEmailMissedInHeader = "user email not in header" | ||
|
||
if reqCtx.UserEmail == "" { | ||
utils.WriteErrMsg(w, http.StatusUnauthorized, errEmailMissedInHeader) | ||
return | ||
} | ||
|
||
teamListResp, err := h.service.UserWardenTeamList(r.Context(), reqCtx.UserEmail) | ||
if err != nil { | ||
utils.WriteErr(w, err) | ||
return | ||
} | ||
|
||
utils.WriteJSON(w, http.StatusOK, map[string]any{ | ||
"teams": teamListResp, | ||
}) | ||
} | ||
|
||
func (h *handler) linkGroupToWarden(w http.ResponseWriter, r *http.Request) { | ||
groupID := chi.URLParam(r, "group_id") | ||
|
||
var body struct { | ||
WardenTeamID string `json:"warden_team_id"` | ||
} | ||
if err := utils.ReadJSON(r, &body); err != nil { | ||
utils.WriteErr(w, err) | ||
return | ||
} else if body.WardenTeamID == "" { | ||
utils.WriteErrMsg(w, http.StatusBadRequest, "missing warden_team_id") | ||
return | ||
} | ||
|
||
resShield, err := h.service.LinkGroupToWarden(r.Context(), groupID, body.WardenTeamID) | ||
if err != nil { | ||
utils.WriteErr(w, err) | ||
return | ||
} | ||
|
||
utils.WriteJSON(w, http.StatusOK, resShield) | ||
} |
Oops, something went wrong.