@@ -1618,11 +1618,15 @@ func (p *pluginResourceWrapper) UnmarshalJSON(data []byte) error {
1618
1618
settingsEntraID = "entra_id"
1619
1619
settingsDatadogIncidentManagement = "datadog_incident_management"
1620
1620
settingsEmailAccessPlugin = "email_access_plugin"
1621
+ settingsAWSIdentityCenter = "aws_ic"
1621
1622
)
1622
1623
type unknownPluginType struct {
1623
1624
Spec struct {
1624
1625
Settings map [string ]json.RawMessage `json:"Settings"`
1625
1626
} `json:"spec"`
1627
+ Status struct {
1628
+ Details map [string ]json.RawMessage `json:"Details"`
1629
+ } `json:"status"`
1626
1630
Credentials struct {
1627
1631
Credentials map [string ]json.RawMessage `json:"Credentials"`
1628
1632
} `json:"credentials"`
@@ -1658,8 +1662,7 @@ func (p *pluginResourceWrapper) UnmarshalJSON(data []byte) error {
1658
1662
}
1659
1663
}
1660
1664
1661
- for k := range unknownPlugin .Spec .Settings {
1662
-
1665
+ for k , value := range unknownPlugin .Spec .Settings {
1663
1666
switch k {
1664
1667
case settingsSlackAccessPlugin :
1665
1668
p .PluginV1 .Spec .Settings = & types.PluginSpecV1_SlackAccessPlugin {}
@@ -1689,17 +1692,99 @@ func (p *pluginResourceWrapper) UnmarshalJSON(data []byte) error {
1689
1692
p .PluginV1 .Spec .Settings = & types.PluginSpecV1_Datadog {}
1690
1693
case settingsEmailAccessPlugin :
1691
1694
p .PluginV1 .Spec .Settings = & types.PluginSpecV1_Email {}
1695
+ case settingsAWSIdentityCenter :
1696
+ settings := & types.PluginSpecV1_AwsIc {
1697
+ AwsIc : & types.PluginAWSICSettings {},
1698
+ }
1699
+ p .PluginV1 .Spec .Settings = settings
1700
+
1701
+ unmshallingWrapper := icSettingsWrapper {inner : settings .AwsIc }
1702
+ if err := json .Unmarshal (value , & unmshallingWrapper ); err != nil {
1703
+ return trace .Wrap (err )
1704
+ }
1692
1705
default :
1693
1706
return trace .BadParameter ("unsupported plugin type: %v" , k )
1694
1707
}
1695
1708
}
1696
1709
1710
+ if len (unknownPlugin .Status .Details ) > 1 {
1711
+ return trace .BadParameter ("malformed status details" )
1712
+ }
1713
+ for k := range unknownPlugin .Status .Details {
1714
+ switch k {
1715
+ case settingsAWSIdentityCenter :
1716
+ p .PluginV1 .Status .Details = & types.PluginStatusV1_AwsIc {}
1717
+ }
1718
+ }
1719
+
1697
1720
if err := json .Unmarshal (data , & p .PluginV1 ); err != nil {
1698
1721
return err
1699
1722
}
1700
1723
return nil
1701
1724
}
1702
1725
1726
+ // icSettingsWrapper is a wrapper around the Identity Center plugin settings to
1727
+ // provide custom unmarshalling.
1728
+ type icSettingsWrapper struct {
1729
+ inner * types.PluginAWSICSettings
1730
+ }
1731
+
1732
+ // UnmarshalJSON implements custom JSON-unmarshaling for the Identity Center
1733
+ // plugin settings. This custom unmarshaler is required to unpack the structure
1734
+ // of the polymorphic filters in the plugin settings, which otherise cannot be
1735
+ // unpacked.
1736
+ func (s * icSettingsWrapper ) UnmarshalJSON (data []byte ) error {
1737
+ type resourceFilter struct {
1738
+ Include map [string ]json.RawMessage `json:"Include"`
1739
+ }
1740
+
1741
+ var settings struct {
1742
+ AccountFilters []resourceFilter `json:"aws_accounts_filters"`
1743
+ GroupFilters []resourceFilter `json:"group_sync_filters"`
1744
+ }
1745
+
1746
+ // unpackFilters only creates the structure of the filters so that the
1747
+ // normal JSON unmarshaller knows how to fill in the actual values
1748
+ unpackFilters := func (src []resourceFilter ) ([]* types.AWSICResourceFilter , error ) {
1749
+ var dst []* types.AWSICResourceFilter
1750
+ for _ , f := range src {
1751
+ if len (f .Include ) != 1 {
1752
+ return nil , trace .BadParameter ("Malformed filter" )
1753
+ }
1754
+ for k := range f .Include {
1755
+ switch k {
1756
+ case "id" :
1757
+ dst = append (dst , & types.AWSICResourceFilter {Include : & types.AWSICResourceFilter_Id {}})
1758
+
1759
+ case "name_regex" :
1760
+ dst = append (dst , & types.AWSICResourceFilter {Include : & types.AWSICResourceFilter_NameRegex {}})
1761
+
1762
+ default :
1763
+ return nil , trace .BadParameter ("Unexpected filter key: %s" , k )
1764
+ }
1765
+ }
1766
+ }
1767
+ return dst , nil
1768
+ }
1769
+
1770
+ if err := json .Unmarshal (data , & settings ); err != nil {
1771
+ return trace .Wrap (err )
1772
+ }
1773
+
1774
+ var err error
1775
+ s .inner .AwsAccountsFilters , err = unpackFilters (settings .AccountFilters )
1776
+ if err != nil {
1777
+ return trace .Wrap (err )
1778
+ }
1779
+
1780
+ s .inner .GroupSyncFilters , err = unpackFilters (settings .GroupFilters )
1781
+ if err != nil {
1782
+ return trace .Wrap (err )
1783
+ }
1784
+
1785
+ return nil
1786
+ }
1787
+
1703
1788
func (c * pluginCollection ) resources () []types.Resource {
1704
1789
r := make ([]types.Resource , len (c .plugins ))
1705
1790
for i , resource := range c .plugins {
0 commit comments