Skip to content

Commit

Permalink
Add requireReason (bool) to GET /webapi/sites/:site/context
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiczko committed Nov 25, 2024
1 parent 9215096 commit c4951fc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ func (h *Handler) getUserContext(w http.ResponseWriter, r *http.Request, p httpr
userContext.AccessCapabilities = ui.AccessCapabilities{
RequestableRoles: res.RequestableRoles,
SuggestedReviewers: res.SuggestedReviewers,
RequireReason: res.RequireReason,
}

userContext.AllowedSearchAsRoles = accessChecker.GetAllowedSearchAsRoles()
Expand Down
3 changes: 3 additions & 0 deletions lib/web/ui/usercontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type AccessCapabilities struct {
RequestableRoles []string `json:"requestableRoles"`
// SuggestedReviewers is a list of reviewers that the user can select when creating a request.
SuggestedReviewers []string `json:"suggestedReviewers"`
// RequireReason indicates whether the reason is required for the user to create an Access
// Request.
RequireReason bool `json:"requireReason"`
}

type authType string
Expand Down
1 change: 1 addition & 0 deletions web/packages/teleport/src/services/user/makeUserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function makeAccessCapabilities(json): AccessCapabilities {
return {
requestableRoles: json.requestableRoles || [],
suggestedReviewers: json.suggestedReviewers || [],
requireReason: json.requireReason || false,
};
}

Expand Down
1 change: 1 addition & 0 deletions web/packages/teleport/src/services/user/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface AccessStrategy {
export interface AccessCapabilities {
requestableRoles: string[];
suggestedReviewers: string[];
requireReason: boolean;
}

export interface UserContext {
Expand Down

0 comments on commit c4951fc

Please sign in to comment.