Commit Graph

138 Commits

Author SHA1 Message Date
mosen
aa0a31bec2 Fix comma in mdmEnrollResponse (#23)
* Stub new method for application datastore
Handle command failures more gracefully than continuously retrying. Failures are not logged
Add table for certificates.

(cherry picked from commit 9f580a6)

* Remove methods with signature NewDatastore() from datastores and injection of the logger instance into each datastore because groob is a doodoo head :)
Move NewDatastore methods into unit tests
Reinstate NewDB test
Create certificates package including a Certificate type and a datastore.
Began working on a method ackCertificateList in the connect service.
Boilerplate for management service test.
Renamed some tables in certificates migration, hopefully nobody notices.
Applications response handler should be omitted from this branch.

(cherry picked from commit 8bc2fc7)

* Add device uuid to certificate, as there will never be a normalised form of the certificate data.
Change statments to reflect table change from certificates to devices_certificates
Add the CertificateList request type to the connect service's Acknowledge method
Add certificates datastore to the management service, and add endpoints and request/responses for retrieving certificates by device uuid to the management endpoujnt.
Kludge. commits regarding app service will be amended.
(cherry picked from commit c723c80)

* Don't forget the endpoint definition for certificates!

(cherry picked from commit 4e5fc1f)

* Use byte field for certificate data.

(cherry picked from commit 66d5036)

* Fix empty import in certificates

(cherry picked from commit b6d4dca)

* Add table for certificates.

(cherry picked from commit 06bc231)

* Renamed some tables in certificates migration, hopefully nobody notices.
Rebase develop onto master

(cherry picked from commit 775484d)

* Certificate list responses are saved via replacing the entire certificate list on a per device basis. This is because neither the common name nor the data could be used as a unique constraint in the certificates table.
Few small changes to imports/style.

(cherry picked from commit e0a63e1)

* Properly rollback if certificate insert fails for any certificate in a response.

(cherry picked from commit 99e1ea1)

* Fix several incorrect statements and struct tags which were preventing the certificates management endpoint from listing certs.
Certificate listing is working without a base64 encoded representation of each certificate.

(cherry picked from commit 685dfef)

* Add commands index to command datastore.
Add simple test for commands index
Add commands index endpoint

(cherry picked from commit 4e2a2a2)

* Add handler for GET /mdm/commands

(cherry picked from commit ae71b8f)

* Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service.
Added Find() method to command service

(cherry picked from commit ebceb28)

* Fix globally scoped vars in command datastore test suite

* groob prefers inline definition of struct members.

* Uppercase CommandUuid

* Add ackCertificateList to connect service, accidentally omitted from installed_certificate_list PR #14
Make push endpoint conform to Errorer interface.
Wrap error return in management service.
Add missing certsDB in main.go, should have been part of installed_certificate_list PR #14

* Fix erraneous comma in mdmEnrollResponse
2016-10-07 12:20:16 +11:00
mosen
487f6826b0 Items that were omitted from cherry picking of installed_certificates_list (#22)
* Stub new method for application datastore
Handle command failures more gracefully than continuously retrying. Failures are not logged
Add table for certificates.

(cherry picked from commit 9f580a6)

* Remove methods with signature NewDatastore() from datastores and injection of the logger instance into each datastore because groob is a doodoo head :)
Move NewDatastore methods into unit tests
Reinstate NewDB test
Create certificates package including a Certificate type and a datastore.
Began working on a method ackCertificateList in the connect service.
Boilerplate for management service test.
Renamed some tables in certificates migration, hopefully nobody notices.
Applications response handler should be omitted from this branch.

(cherry picked from commit 8bc2fc7)

* Add device uuid to certificate, as there will never be a normalised form of the certificate data.
Change statments to reflect table change from certificates to devices_certificates
Add the CertificateList request type to the connect service's Acknowledge method
Add certificates datastore to the management service, and add endpoints and request/responses for retrieving certificates by device uuid to the management endpoujnt.
Kludge. commits regarding app service will be amended.
(cherry picked from commit c723c80)

* Don't forget the endpoint definition for certificates!

(cherry picked from commit 4e5fc1f)

* Use byte field for certificate data.

(cherry picked from commit 66d5036)

* Fix empty import in certificates

(cherry picked from commit b6d4dca)

* Add table for certificates.

(cherry picked from commit 06bc231)

* Renamed some tables in certificates migration, hopefully nobody notices.
Rebase develop onto master

(cherry picked from commit 775484d)

* Certificate list responses are saved via replacing the entire certificate list on a per device basis. This is because neither the common name nor the data could be used as a unique constraint in the certificates table.
Few small changes to imports/style.

(cherry picked from commit e0a63e1)

* Properly rollback if certificate insert fails for any certificate in a response.

(cherry picked from commit 99e1ea1)

* Fix several incorrect statements and struct tags which were preventing the certificates management endpoint from listing certs.
Certificate listing is working without a base64 encoded representation of each certificate.

(cherry picked from commit 685dfef)

* Add commands index to command datastore.
Add simple test for commands index
Add commands index endpoint

(cherry picked from commit 4e2a2a2)

* Add handler for GET /mdm/commands

(cherry picked from commit ae71b8f)

* Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service.
Added Find() method to command service

(cherry picked from commit ebceb28)

* Fix globally scoped vars in command datastore test suite

* groob prefers inline definition of struct members.

* Uppercase CommandUuid

* Add ackCertificateList to connect service, accidentally omitted from installed_certificate_list PR #14
Make push endpoint conform to Errorer interface.
Wrap error return in management service.
Add missing certsDB in main.go, should have been part of installed_certificate_list PR #14
2016-10-07 11:57:04 +11:00
mosen
b3e97c53b2 installed_certificates #14 plus conflict resolution (#21)
* Stub new method for application datastore
Handle command failures more gracefully than continuously retrying. Failures are not logged
Add table for certificates.

(cherry picked from commit 9f580a6)

* Remove methods with signature NewDatastore() from datastores and injection of the logger instance into each datastore because groob is a doodoo head :)
Move NewDatastore methods into unit tests
Reinstate NewDB test
Create certificates package including a Certificate type and a datastore.
Began working on a method ackCertificateList in the connect service.
Boilerplate for management service test.
Renamed some tables in certificates migration, hopefully nobody notices.
Applications response handler should be omitted from this branch.

(cherry picked from commit 8bc2fc7)

* Add device uuid to certificate, as there will never be a normalised form of the certificate data.
Change statments to reflect table change from certificates to devices_certificates
Add the CertificateList request type to the connect service's Acknowledge method
Add certificates datastore to the management service, and add endpoints and request/responses for retrieving certificates by device uuid to the management endpoujnt.
Kludge. commits regarding app service will be amended.
(cherry picked from commit c723c80)

* Don't forget the endpoint definition for certificates!

(cherry picked from commit 4e5fc1f)

* Use byte field for certificate data.

(cherry picked from commit 66d5036)

* Fix empty import in certificates

(cherry picked from commit b6d4dca)

* Add table for certificates.

(cherry picked from commit 06bc231)

* Renamed some tables in certificates migration, hopefully nobody notices.
Rebase develop onto master

(cherry picked from commit 775484d)

* Certificate list responses are saved via replacing the entire certificate list on a per device basis. This is because neither the common name nor the data could be used as a unique constraint in the certificates table.
Few small changes to imports/style.

(cherry picked from commit e0a63e1)

* Properly rollback if certificate insert fails for any certificate in a response.

(cherry picked from commit 99e1ea1)

* Fix several incorrect statements and struct tags which were preventing the certificates management endpoint from listing certs.
Certificate listing is working without a base64 encoded representation of each certificate.

(cherry picked from commit 685dfef)

* Add commands index to command datastore.
Add simple test for commands index
Add commands index endpoint

(cherry picked from commit 4e2a2a2)

* Add handler for GET /mdm/commands

(cherry picked from commit ae71b8f)

* Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service.
Added Find() method to command service

(cherry picked from commit ebceb28)

* Fix globally scoped vars in command datastore test suite

* groob prefers inline definition of struct members.

* Uppercase CommandUuid
2016-10-07 11:34:50 +11:00
mosen
bd5d996d73 Commands management plus fixes (#20)
* Add commands index to command datastore.
Add simple test for commands index
Add commands index endpoint

(cherry picked from commit 4e2a2a2)

* Add handler for GET /mdm/commands

(cherry picked from commit ae71b8f)

* Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service.
Added Find() method to command service

(cherry picked from commit ebceb28)

* Fix globally scoped vars in command datastore test suite

* groob prefers inline definition of struct members.

* Uppercase CommandUuid
2016-10-07 11:17:47 +11:00
mosen
397087a800 Installed application list (#18)
* Add table `applications` and `devices_applications` for tracking installed applications per device and total installed application count.

(cherry picked from commit fba935d)

* Define new datastore for retrieving installed applications by device uuid
Add InstalledApps method to management service
Add endpoint for installed applications at /management/v1/devices/uuid/applications

(cherry picked from commit 07b2deb)

* REMOVED: Flesh out implementation of acknowledging InstalledApplicationList response.
Additional tags on Application for database.
Applications datastore supports select with arbitrary where clauses
Changed the signatures of all the ack handlers in connect service.

(cherry picked from commit f16b776)

* Revert acknowledge handlers code.
Add stub for acknowledging installed applications list.

(cherry picked from commit 82f7e3a)

* Fix some error strings in application datastore which still referred to devices.
Add method SaveApplicationByDeviceUUID to add rows to `devices_applications` for the specified device uuid
Add method NewDatastore since NewDB was untestable using mocks.
Connect service now takes an applications datastore as one of its parameters.
ackInstalledApplicationList implemented but not tested for InstallApplicationList responses.

(cherry picked from commit 97a97d9)

* Further comments on applications datastore.
Attempt to make some where clause helper functions.
Expand test suites to cover many different type of installed applications.
All tests passing.

(cherry picked from commit be99fcd)

* Additional comments
Fix methods which returned a pointer to a slice which is pointless.
Moved statement building functions in applications package to statement.go.
Fixed acknowledge handler if device UDID does not match any enrolled device (happens a lot in test cases).
Preliminary re-implementation of ackInstalledApplicationList
Added tests for the connect service.

(cherry picked from commit 92f253c)

* Add basic test for ackInstalledApplicationList

(cherry picked from commit 66ec74c)

* Fix wrong positional parameters.
Add handler for InstalledApplicationList request type.
installed applications are inserted but their relationship to the current device is not yet recorded. work in progress.

(cherry picked from commit e90c78d)

* Fixed slices which used make() showing the wrong capacity.
Removed a bunch of debug print statements.
Further enhanced connect service test with sql mocking.

(cherry picked from commit 0913934)

* Add regression test for bundle with size that is too large for int field.
Change applications table migration to use bigint field for `bundle_size`

(cherry picked from commit 3038d17)

* Note about difference between iOS and macOS Responses in comments.
Handle iOS response to InstalledApplicationList
Empty test for duplicate applications regression
Update management service test to fit new signature for NewService()

(cherry picked from commit db7c431)

* Changed application response storage to devices_applications, similar to certificates. Every time the device reports a new list, the application list gets replaced.
Add PayloadScope to enroll endpoint because interactive enrollment always seems to try to use the User scope.

(cherry picked from commit 0b0a01d)

* Merge change that removes NewDatastore() from applications/datastore.

* Add setup and teardown to application datastore test.
Remove existing tests because they were using the old Datastore interface.

* Remove invalid imports whoops

* Removed commented code.
Imported name device clashed with variable name device, renamed.

* Fix applications datastore New method in connect service test suite.

* Pull all vars out of global scope in connect service test.
2016-10-07 10:55:12 +11:00
mosen
2015126c65 Enrollment (#13)
* Add flag url (MICROMDM_PUBLIC_URL) for public facing mdm enrollment url.
Add flag scep-url (MICROMDM_SCEP_URL) for scep payload in enrollment profile.

(cherry picked from commit 1cc09e3)

* enroll service allows scep challenge via flag --scep-challenge or env MICROMDM_SCEP_CHALLENGE
remove reference to certificates and apps, those will be in other branches.
(cherry picked from commit e417ba8)

* Add MDM payload
Add NewPayload method
Profiles and payloads created by their factory methods automatically generate a UUID
Add go-kit service for enroll.
Merge rebase for enroll service

(cherry picked from commit 6843b20)

* Fleshed out a bit more of the enroll service.
Rebase onto master

(cherry picked from commit 69dc230)

* Add endpoint and transport for Enroll service.
Rebase develop onto master

(cherry picked from commit 1501b2e)

* Fix several compilation errors regarding syntax.
Rebase develop onto master

(cherry picked from commit fe3d039)

* More consistent naming of Payloads.
Merge develop onto master

(cherry picked from commit 6f70231)

* Fix error with plist encoding by dereferencing nested payloads.
Add correct header for enrollment profile.
Enrollment works with micromdm/scep server!
Rebase develop onto master

(cherry picked from commit 7e858c3)

* Warnings are more helpful if you omit pieces of configuration.
CA payload for SCEP includes identifier.
CORS methods, app service, cert service omitted for this commit, will be cherry picked into a different branch.

(cherry picked from commit 9219be2)

* enroll package follows the style of go-kit

(cherry picked from commit fb03d3c)

* Fix variable naming of URL and SCEPURL.
Remove duplicate enroll service.

* Fix variable naming in main URL, SCEP, CORS

* Fix errors returned in mdmEnrollResponse.
2016-10-07 10:13:26 +11:00
mosen
8b526c6aaa Add column unlock_token (#19)
Store unlock_token on TokenUpdate message.

(cherry picked from commit bcb16fc)
2016-10-07 10:00:00 +11:00
mosen
a332f3cb75 Add warning when CORS feature is disabled. (#17)
Add PATCH and DELETE methods to CORS because we do expose some of those in our endpoints.

(cherry picked from commit 9445d93)
2016-10-07 09:59:15 +11:00
mosen
a9959f7e30 Add depsim/vppsim containers. (#15)
(cherry picked from commit 830b264)
2016-10-07 09:58:40 +11:00
Mosen
98df3c11a9 Make public facing URL and SCEP server URL configurable.
Degrade gracefully to disabling enrollment endpoint if either URL or SCEP url are not provided.
2016-07-11 14:54:46 -04:00
Mosen
49fa779d1c Add cli flag tls-ca-cert and environment var MICROMDM_TLS_CA_CERT to specify a CA certificate which will be included in the enrollment profile. This is handy if you are using self signed certificates and you need to establish a CA trust. 2016-07-11 14:54:46 -04:00
Mosen
3ca4e954e8 Newer clients provide DeviceName in their checkin message, so this has been added to the checkin service. 2016-07-11 14:54:46 -04:00
Mosen
e2492daddc Parse APNS Topic from push certificate in enroll service constructor. 2016-07-11 14:54:46 -04:00
Mosen
82f657ef6a Fix error with plist encoding by dereferencing nested payloads.
Add correct header for enrollment profile.
Enrollment works with micromdm/scep server!
2016-07-11 14:54:46 -04:00
Mosen
2cac88f6e4 More consistent naming of Payloads. 2016-07-11 14:54:46 -04:00
Mosen
a68c3e0014 Fix several compilation errors regarding syntax. 2016-07-11 14:54:46 -04:00
Mosen
19de87db9a Add endpoint and transport for Enroll service. 2016-07-11 14:54:46 -04:00
Mosen
9ee2d63ded Fleshed out a bit more of the enroll service. 2016-07-11 14:54:46 -04:00
Mosen
afa4cac017 Add MDM payload
Add NewPayload method
Profiles and payloads created by their factory methods automatically generate a UUID
Add go-kit service for enroll.
2016-07-11 14:54:46 -04:00
Mosen
948a1d2e6b Begin adding /mdm/enroll service. 2016-07-11 14:54:46 -04:00
Mosen
61509d7e75 Handle errors when scanning serial number and udid for insertion when device checks in.
Update udid when device checks in.
2016-06-29 20:09:50 +10:00
Mosen
198b3b4720 Create type JsonNullString to allow NullString marshalling to JSON value. 2016-06-29 19:44:37 +10:00
Mosen
ee6107b52f Use sql.NullString where possible to allow us to put unique constraints on both UDID and SerialNumber
Remove default of empty string '' from udid column.
2016-06-29 19:01:26 +10:00
Mosen
b35d697ad9 Add a few more statements to the up and down migrations for the new unique constraints so that the data will fit the constraints if up or downgraded.
Use sql.NullString for UDID and SerialNumber.
2016-06-28 20:08:49 +10:00
Mosen
2c388edc11 Go back to unique indexes on serial number and udid. Will use NullString on those struct columns. 2016-06-28 19:59:35 +10:00
Mosen
0bbdb50415 Change type assertion in DEPProfileStatus.Scan() to string. 2016-06-26 23:11:36 +10:00
Mosen
80eacdbfac Add parameter "separator" to addWhereFilters() 2016-06-26 23:05:34 +10:00
Mosen
586ba922b3 Do not capitalize errors. 2016-06-26 22:51:54 +10:00
Mosen
9a364d5c86 Use device datastore .Devices() method instead of GetDeviceByUDID.
Query by both device.SerialNumber and device.UDID
join WHERE conditions using the OR logical operator. I can't determine whether this has an impact elsewhere.
2016-06-25 22:19:39 +10:00
Mosen
d69becfd53 Add UDID as a filter to device datastore Devices() so that we can hopefully combine UDID with SerialNumber and abandon GetDeviceByUDID in Acknowledge. 2016-06-25 22:09:53 +10:00
Mosen
e0aa275058 Actually include some fields in ackQueryResponses when fetching a Device to fix device query response update. 2016-06-25 22:02:47 +10:00
Mosen
00c8c9247f Set LastQueryResponse to byte slice.
Marshal LastQueryResponse to JSON in connect.Service
2016-06-24 16:26:20 +10:00
Mosen
0c7a80b720 Omit last_query_response from changes. 2016-06-24 15:31:49 +10:00
Mosen
7388e1c9be Add update statements so existing devices dont break the not null constraints. 2016-06-24 15:02:34 +10:00
Mosen
85ba80a03f Add default values for several new fields added to devices. 2016-06-24 14:59:18 +10:00
Mosen
79acadd3a2 Fix unique constraint in query fetchDevicesDEP 2016-06-24 14:32:37 +10:00
Victor Vrantchan
4356d9e053 update deps 2016-06-23 08:29:52 -04:00
Mosen
2d08b9388e This time with the correct underlying Response struct in the connect endpoint. 2016-06-23 22:00:37 +10:00
Mosen
80aedab989 Converting request to mdm.Response was a bad idea. panic.
Update statement to reflect new composite key of udid and serial_number.
2016-06-23 17:33:14 +10:00
Mosen
3da3a3555e Remove unused packages. 2016-06-23 14:09:10 +10:00
Mosen
5f73d44d8e Cast request object to mdm.Response in connect endpoint.
use devices.Save in ackQueryResponses
Remove methods UpdateDeviceQueryResponseByUDID and UpdateDeviceCheckinByUDID
Add message to devices.Save switch block for updating Query Responses.
2016-06-23 14:08:34 +10:00
Mosen
a89efaa2c0 Ditch checkin middleware.
Add QueryResponses to Device struct.
Move checkin update to ackQueryResponses.
2016-06-23 13:55:39 +10:00
Mosen
985db5752e Fix declaration of err variable in connect.Service.Acknowledge 2016-06-23 13:46:24 +10:00
Mosen
7ec8f51f70 Fix wrong method signature in connect.Service, thanks groob. 2016-06-23 13:40:51 +10:00
Mosen
bc3cded620 Add device name to result in devices list.
Fix default and not null constraints on device_name field.
2016-06-22 20:09:52 +10:00
Mosen
5c6daeda6e Add device name field to Device struct. 2016-06-22 20:02:48 +10:00
Mosen
3d08a855e8 Add migrations for fields last_checkin and device_name. 2016-06-22 20:01:42 +10:00
Mosen
68e86c16b4 Devices endpoint reports field last_checkin for each device. 2016-06-22 19:25:00 +10:00
Mosen
4d744fef03 Go fmt
Add fields returned by the management devices endpoint.
2016-06-22 19:13:14 +10:00
Mosen
15b5ec5cef Add service middleware for Connect service to record last_checkin each time a device contacts the MDM
Add method UpdateDeviceCheckinByUDID to device.Datastore which updates the current checkin timestamp for a given device.
Middleware set up in main.go
2016-06-22 19:10:38 +10:00