Fix slack connector permission
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -263,6 +263,9 @@ const (
|
|||||||
ActionMeetingUpdate = "core:meeting:update"
|
ActionMeetingUpdate = "core:meeting:update"
|
||||||
ActionMeetingDelete = "core:meeting:delete"
|
ActionMeetingDelete = "core:meeting:delete"
|
||||||
|
|
||||||
|
// Connector actions
|
||||||
|
ActionConnectorInitiate = "core:connector:initiate"
|
||||||
|
|
||||||
// SlackConnection actions
|
// SlackConnection actions
|
||||||
ActionSlackConnectionList = "core:slack-connection:list"
|
ActionSlackConnectionList = "core:slack-connection:list"
|
||||||
|
|
||||||
|
|||||||
@@ -225,20 +225,23 @@ func NewMux(
|
|||||||
panic(fmt.Errorf("cannot parse organization id: %w", err))
|
panic(fmt.Errorf("cannot parse organization id: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
identity := connect_v1.IdentityFromContext(r.Context())
|
|
||||||
apiKey := connect_v1.APIKeyFromContext(r.Context())
|
apiKey := connect_v1.APIKeyFromContext(r.Context())
|
||||||
|
if apiKey != nil {
|
||||||
|
httpserver.RenderError(w, http.StatusBadRequest, fmt.Errorf("api key authentication cannot be used for this endpoint"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
identity := connect_v1.IdentityFromContext(r.Context())
|
||||||
if identity == nil {
|
if identity == nil {
|
||||||
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var credentialID *gid.GID
|
if err := iamSvc.Authorizer.Authorize(r.Context(), iam.AuthorizeParams{
|
||||||
if apiKey != nil {
|
Principal: identity.ID,
|
||||||
credentialID = &apiKey.ID
|
Resource: organizationID,
|
||||||
}
|
Action: probo.ActionConnectorInitiate,
|
||||||
|
}); err != nil {
|
||||||
// Ensure the actor (and optional API key) can access this organization.
|
|
||||||
if err := iamSvc.LegacyAccessManagementService.Authorize(r.Context(), identity.ID, credentialID, organizationID, iam.ActionGet); err != nil {
|
|
||||||
httpserver.RenderError(w, http.StatusForbidden, err)
|
httpserver.RenderError(w, http.StatusForbidden, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user