2025-02-13 20:32:19 +00:00
|
|
|
package android
|
|
|
|
|
|
2025-02-24 20:31:21 +00:00
|
|
|
import (
|
2025-12-02 17:27:20 +00:00
|
|
|
"database/sql"
|
2025-02-24 20:31:21 +00:00
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2025-12-02 17:27:20 +00:00
|
|
|
const DefaultAndroidPolicyID = 1
|
|
|
|
|
|
2025-02-13 20:32:19 +00:00
|
|
|
type SignupDetails struct {
|
2025-02-18 15:43:11 +00:00
|
|
|
Url string
|
|
|
|
|
Name string
|
2025-02-13 20:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Enterprise struct {
|
|
|
|
|
ID uint `db:"id"`
|
|
|
|
|
EnterpriseID string `db:"enterprise_id"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Enterprise) Name() string {
|
|
|
|
|
return "enterprises/" + e.EnterpriseID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e Enterprise) IsValid() bool {
|
|
|
|
|
return e.EnterpriseID != ""
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-18 15:43:11 +00:00
|
|
|
func (e Enterprise) AuthzType() string {
|
|
|
|
|
return "android_enterprise"
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 20:31:21 +00:00
|
|
|
type EnterpriseDetails struct {
|
|
|
|
|
Enterprise
|
|
|
|
|
SignupName string `db:"signup_name"`
|
|
|
|
|
SignupToken string `db:"signup_token"`
|
|
|
|
|
TopicID string `db:"pubsub_topic_id"`
|
2025-02-27 20:19:15 +00:00
|
|
|
UserID uint `db:"user_id"`
|
2025-02-24 20:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-13 20:32:19 +00:00
|
|
|
type EnrollmentToken struct {
|
2025-02-24 20:31:21 +00:00
|
|
|
EnrollmentToken string `json:"android_enrollment_token"`
|
|
|
|
|
EnrollmentURL string `json:"android_enrollment_url"`
|
2025-02-13 20:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-24 20:31:21 +00:00
|
|
|
type Device struct {
|
|
|
|
|
ID uint `db:"id"`
|
|
|
|
|
HostID uint `db:"host_id"`
|
|
|
|
|
DeviceID string `db:"device_id"`
|
|
|
|
|
EnterpriseSpecificID *string `db:"enterprise_specific_id"`
|
|
|
|
|
LastPolicySyncTime *time.Time `db:"last_policy_sync_time"`
|
2025-09-22 15:29:57 +00:00
|
|
|
AppliedPolicyID *string `db:"applied_policy_id"`
|
|
|
|
|
AppliedPolicyVersion *int64 `db:"applied_policy_version"`
|
2025-02-13 20:32:19 +00:00
|
|
|
}
|
2025-11-21 20:42:24 +00:00
|
|
|
|
|
|
|
|
type AgentManagedConfiguration struct {
|
2025-12-01 23:30:18 +00:00
|
|
|
ServerURL string `json:"server_url"`
|
|
|
|
|
HostUUID string `json:"host_uuid"`
|
|
|
|
|
EnrollSecret string `json:"enroll_secret"`
|
Sync app with server vars, fix retry logic (#36923)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #36591
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
- [ ] 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/guides/committing-changes.md#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes
## Testing
- [ ] Added/updated automated tests
- [ ] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)
- [ ] QA'd all new/changed functionality manually
For unreleased bug fixes in a release candidate, one of:
- [ ] Confirmed that the fix is not expected to adversely impact load
test results
- [ ] Alerted the release DRI if additional load testing is needed
## Database migrations
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
## New Fleet configuration settings
- [ ] Setting(s) is/are explicitly excluded from GitOps
If you didn't check the box above, follow this checklist for
GitOps-enabled settings:
- [ ] Verified that the setting is exported via `fleetctl
generate-gitops`
- [ ] Verified the setting is documented in a separate PR to [the GitOps
documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485)
- [ ] Verified that the setting is cleared on the server if it is not
supplied in a YAML file (or that it is documented as being optional)
- [ ] Verified that any relevant UI is disabled when GitOps mode is
enabled
## fleetd/orbit/Fleet Desktop
- [ ] Verified compatibility with the latest released version of Fleet
(see [Must
rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md))
- [ ] If the change applies to only one platform, confirmed that
`runtime.GOOS` is used as needed to isolate changes
- [ ] Verified that fleetd runs on macOS, Linux and Windows
- [ ] Verified auto-update works from the released version of component
to the new version (see [tools/tuf/test](../tools/tuf/test/README.md))
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Release Notes
* **New Features**
* Added automatic retry mechanism for failed certificate installations
with up to 3 retry attempts.
* Enhanced certificate installation status tracking and visibility.
* **Bug Fixes**
* Improved error handling and detailed error reporting for certificate
enrollment failures.
* **Tests**
* Added comprehensive test coverage for certificate enrollment and
status tracking workflows.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Victor Lyuboslavsky <2685025+getvictor@users.noreply.github.com>
2025-12-10 23:50:38 +00:00
|
|
|
CertificateTemplateIDs []AgentCertificateTemplate `json:"certificate_templates,omitempty"`
|
2025-12-01 23:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AgentCertificateTemplate struct {
|
2026-01-06 16:20:07 +00:00
|
|
|
ID uint `json:"id"`
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
Operation string `json:"operation"`
|
|
|
|
|
UUID string `json:"uuid"`
|
2025-11-21 20:42:24 +00:00
|
|
|
}
|
2025-12-02 17:27:20 +00:00
|
|
|
|
|
|
|
|
// MDMAndroidPolicyRequest represents a request made to the Android Management
|
|
|
|
|
// API (AMAPI) to patch the policy or the device (as made by
|
|
|
|
|
// androidsvc.ReconcileProfiles).
|
|
|
|
|
type MDMAndroidPolicyRequest struct {
|
|
|
|
|
RequestUUID string `db:"request_uuid"`
|
|
|
|
|
RequestName string `db:"request_name"`
|
|
|
|
|
PolicyID string `db:"policy_id"`
|
|
|
|
|
Payload []byte `db:"payload"`
|
|
|
|
|
StatusCode int `db:"status_code"`
|
|
|
|
|
ErrorDetails sql.Null[string] `db:"error_details"`
|
|
|
|
|
AppliedPolicyVersion sql.Null[int64] `db:"applied_policy_version"`
|
|
|
|
|
PolicyVersion sql.Null[int64] `db:"policy_version"`
|
|
|
|
|
}
|
2025-12-17 16:44:25 +00:00
|
|
|
|
|
|
|
|
const AppStatusAvailable = "AVAILABLE"
|