|
| 1 | +// jamfproapi_sso_settings.go |
| 2 | +// Jamf Pro Api - SSO Settings |
| 3 | +// api reference: https://developer.jamf.com/jamf-pro/reference/get_v2-sso |
| 4 | +// Jamf Pro API requires the structs to support a JSON data structure. |
| 5 | + |
| 6 | +package jamfpro |
| 7 | + |
| 8 | +import "fmt" |
| 9 | + |
| 10 | +const uriSsoSettings = "/api/v2/sso" |
| 11 | +const uriSsoDependencies = "/api/v2/sso/dependencies" |
| 12 | + |
| 13 | +// Structs |
| 14 | + |
| 15 | +// SSO Settings |
| 16 | +// Resource |
| 17 | + |
| 18 | +type ResourceSsoSettings struct { |
| 19 | + SsoForEnrollmentEnabled bool `json:"ssoForEnrollmentEnabled"` |
| 20 | + SsoBypassAllowed bool `json:"ssoBypassAllowed"` |
| 21 | + SsoEnabled bool `json:"ssoEnabled"` |
| 22 | + SsoForMacOsSelfServiceEnabled bool `json:"ssoForMacOsSelfServiceEnabled"` |
| 23 | + TokenExpirationDisabled bool `json:"tokenExpirationDisabled"` |
| 24 | + UserAttributeEnabled bool `json:"userAttributeEnabled"` |
| 25 | + UserAttributeName string `json:"userAttributeName"` |
| 26 | + UserMapping string `json:"userMapping"` |
| 27 | + EnrollmentSsoForAccountDrivenEnrollmentEnabled bool `json:"enrollmentSsoForAccountDrivenEnrollmentEnabled"` |
| 28 | + EnrollmentSsoConfig SsoSettingsSubsetEnrollmentSsoConfig `json:"enrollmentSsoConfig"` |
| 29 | + GroupEnrollmentAccessEnabled bool `json:"groupEnrollmentAccessEnabled"` |
| 30 | + GroupAttributeName string `json:"groupAttributeName"` |
| 31 | + GroupRdnKey string `json:"groupRdnKey"` |
| 32 | + GroupEnrollmentAccessName string `json:"groupEnrollmentAccessName"` |
| 33 | + IdpProviderType string `json:"idpProviderType"` |
| 34 | + IdpUrl string `json:"idpUrl"` |
| 35 | + EntityId string `json:"entityId"` |
| 36 | + MetadataFileName string `json:"metadataFileName"` |
| 37 | + OtherProviderTypeName string `json:"otherProviderTypeName"` |
| 38 | + FederationMetadataFile string `json:"federationMetadataFile"` |
| 39 | + MetadataSource string `json:"metadataSource"` |
| 40 | + SessionTimeout int `json:"sessionTimeout"` |
| 41 | +} |
| 42 | + |
| 43 | +// Subsets |
| 44 | + |
| 45 | +type SsoSettingsSubsetEnrollmentSsoConfig struct { |
| 46 | + Hosts []string `json:"hosts"` |
| 47 | + ManagementHint string `json:"managementHint"` |
| 48 | +} |
| 49 | + |
| 50 | +// Enrollment Customizations Using SSO |
| 51 | +// Resource |
| 52 | + |
| 53 | +type ResponseSsoSubsetEnrollmentCustomizationDependencyList struct { |
| 54 | + Dependencies []SsoSubsetSubsetEnrollmentCustomizationDependency |
| 55 | +} |
| 56 | + |
| 57 | +// Subset |
| 58 | + |
| 59 | +type SsoSubsetSubsetEnrollmentCustomizationDependency struct { |
| 60 | + Name string `json:"name"` |
| 61 | + HumanReadableName string `json:"humanReadableName"` |
| 62 | + Hyperlink string `json:"hyperlink"` |
| 63 | +} |
| 64 | + |
| 65 | +// CRUD |
| 66 | + |
| 67 | +// GetSsoSettings retrieves current Jamf Sso settings |
| 68 | +func (c *Client) GetSsoSettings() (*ResourceSsoSettings, error) { |
| 69 | + endpoint := uriSsoSettings |
| 70 | + var out ResourceSsoSettings |
| 71 | + resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out) |
| 72 | + if err != nil { |
| 73 | + return nil, fmt.Errorf(errMsgFailedGet, "sso settings", err) |
| 74 | + } |
| 75 | + |
| 76 | + if resp != nil && resp.Body != nil { |
| 77 | + defer resp.Body.Close() |
| 78 | + } |
| 79 | + |
| 80 | + return &out, nil |
| 81 | +} |
| 82 | + |
| 83 | +// UpdateSsoSettings Updates SSO Settings with ResourceSsoSettings struct data |
| 84 | +func (c *Client) UpdateSsoSettings(updatedSettings ResourceSsoSettings) (*ResourceSsoSettings, error) { |
| 85 | + endpoint := uriSsoSettings |
| 86 | + var out ResourceSsoSettings |
| 87 | + resp, err := c.HTTP.DoRequest("PUT", endpoint, updatedSettings, &out) |
| 88 | + if err != nil { |
| 89 | + return nil, fmt.Errorf(errMsgFailedUpdate, "sso settings", err) |
| 90 | + } |
| 91 | + |
| 92 | + if resp != nil && resp.Body != nil { |
| 93 | + defer resp.Body.Close() |
| 94 | + } |
| 95 | + |
| 96 | + return &out, nil |
| 97 | +} |
| 98 | + |
| 99 | +// GetSsoEnrollmentCustomizationDependencies shows which enrollment customizations are dependent on which sso settings // NOTE I think? |
| 100 | +func (c *Client) GetSsoEnrollmentCustomizationDependencies() (*ResponseSsoSubsetEnrollmentCustomizationDependencyList, error) { |
| 101 | + endpoint := uriSsoDependencies |
| 102 | + var out ResponseSsoSubsetEnrollmentCustomizationDependencyList |
| 103 | + resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &out) |
| 104 | + if err != nil { |
| 105 | + return nil, fmt.Errorf(errMsgFailedGet, "sso enrollment customization dependencies", err) |
| 106 | + } |
| 107 | + |
| 108 | + if resp != nil && resp.Body != nil { |
| 109 | + defer resp.Body.Close() |
| 110 | + } |
| 111 | + |
| 112 | + return &out, nil |
| 113 | +} |
| 114 | + |
| 115 | +// QUERY What other endpoints do we need to cover here? It's a bit of a mix mash |
0 commit comments