mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 00:18:27 +00:00
#19447 iOS and iPadOS apps can be installed using Apple's VPP (Volume Purchase Program) VPP apps are now using a composite primary key (Adam ID and platform) because we want to keep iOS/iPadOS/macOS separate. It is possible for one app to be installable on all Apple platforms. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality
74 lines
2.3 KiB
Go
74 lines
2.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Get App Store apps
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
type getAppStoreAppsRequest struct {
|
|
TeamID uint `query:"team_id"`
|
|
}
|
|
|
|
type getAppStoreAppsResponse struct {
|
|
AppStoreApps []*fleet.VPPApp `json:"app_store_apps"`
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r getAppStoreAppsResponse) error() error { return r.Err }
|
|
|
|
func getAppStoreAppsEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (errorer, error) {
|
|
req := request.(*getAppStoreAppsRequest)
|
|
apps, err := svc.GetAppStoreApps(ctx, &req.TeamID)
|
|
if err != nil {
|
|
return &getAppStoreAppsResponse{Err: err}, nil
|
|
}
|
|
|
|
return &getAppStoreAppsResponse{AppStoreApps: apps}, nil
|
|
}
|
|
|
|
func (svc *Service) GetAppStoreApps(ctx context.Context, teamID *uint) ([]*fleet.VPPApp, error) {
|
|
// skipauth: No authorization check needed due to implementation returning
|
|
// only license error.
|
|
svc.authz.SkipAuthorization(ctx)
|
|
|
|
return nil, fleet.ErrMissingLicense
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Add App Store apps
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
type addAppStoreAppRequest struct {
|
|
TeamID *uint `json:"team_id"`
|
|
AppStoreID string `json:"app_store_id"`
|
|
Platform fleet.AppleDevicePlatform `json:"platform"`
|
|
}
|
|
|
|
type addAppStoreAppResponse struct {
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r addAppStoreAppResponse) error() error { return r.Err }
|
|
|
|
func addAppStoreAppEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (errorer, error) {
|
|
req := request.(*addAppStoreAppRequest)
|
|
err := svc.AddAppStoreApp(ctx, req.TeamID, fleet.VPPAppID{AdamID: req.AppStoreID, Platform: req.Platform})
|
|
if err != nil {
|
|
return &addAppStoreAppResponse{Err: err}, nil
|
|
}
|
|
|
|
return &addAppStoreAppResponse{}, nil
|
|
}
|
|
|
|
func (svc *Service) AddAppStoreApp(ctx context.Context, _ *uint, _ fleet.VPPAppID) error {
|
|
// skipauth: No authorization check needed due to implementation returning
|
|
// only license error.
|
|
svc.authz.SkipAuthorization(ctx)
|
|
|
|
return fleet.ErrMissingLicense
|
|
}
|