Commit Graph

159 Commits

Author SHA1 Message Date
Victor Vrantchan
2751a79c86 refactor package main (#49)
move the contents of main.go into app package.
scaffold a CLI subcommands package. 
add a version package and add /_version handler to print detailed version info.
v0.1.2.0-dev
2016-11-13 15:50:36 -05:00
Victor Vrantchan
8e3331f7eb add dependencies for scpe/bolt (#48) v0.1.0.2-dev 2016-11-11 19:03:58 -05:00
mosen
7b11aa8994 SCEP request subject is configurable and you can use it with templated SCEP variables like %SerialNumber% etc. (#45)
SCEP request subject configurable via flag --scep-subject or environment MICROMDM_SCEP_SUBJECT
2016-11-11 14:00:08 +11:00
mosen
9792031ef3 Feature/dep optional (#44)
* Make depclient construction function return an error if the client could not be constructed.

* Make depclient construction function return an error if the client could not be constructed.

* Add "feature not available" message when attempting to fetch dep devices without a configured dep client.
Add test demonstrating the "feature not available" error when constructing the management service without a dep client.

* Make a boolean --dep flag. DEP will be disabled by default, and prints a message to the console to inform the user of the dep feature status.
Incorrect flags when DEP is enabled will now exit with status 1 again.
2016-11-11 13:59:44 +11:00
Victor Vrantchan
ab68bddbaf update vendor dependencies (#46)
update vendored dependencies 
don't make deps by default(using vendor)
2016-11-10 21:47:29 -05:00
mosen
c5530f2053 Remove totally unused service test. (#43)
Update transport test to use new signature of management.Service (NewService)
2016-11-06 21:38:46 +11:00
mosen
8c42e2d7e1 Response testing 1 (#42)
* Create skeleton test suite for connect transport

* Remove service test because sqlmock never made it into the master branch.
Add transport test for connect loosely based on groobs management transport tests.

* Added mock command service.
Add single test for InstalledApplicationList
Add some modified real world responses as test data.

* Create fake device fixture for connect tests

* Add some more macOS responses.
Fix nullstring error in transport test.
proper teardown of httptest server.

* Even more responses from live system to use as test fixtures.

* Cleanup commented code.
Simple test for inserted applications with InstalledApplicationList response.

* Cleanup unused imports.

* Add tests for DeviceInformation and CertificateList.
Try to construct the command request in setup(), dirty hack.

* Use rollback instead of inline statements to destroy fixtures.
Fix incorrect plist in deviceinformation test.
Minor cleanups

* Add checkin authenticate test.
Fix some "down" migrations which didnt actually work.

* Basic coverage of checkin tests.
Fix invalid fixture base64 data.

* Tidy up mock management service and imports.

* Revert back to setup()/teardown() style per discussion with groob.

* Clean up imports
2016-11-06 21:15:46 +11:00
mosen
dfb757db8a FIX: CA roots are not correctly being verified in main.go. Left the warning in but removed os.Exit until we can determine a cross-platform method of evaluating certificate trust. (#41) 2016-10-25 21:59:25 +11:00
mosen
4742bb7bb3 SCEP Subject had incorrect nesting of arrays, which allowed macOS to ignore it, but iOS would refuse enrolment. (#40)
SCEP payload is optional in /mdm/enroll
SCEP challenge is optional in /mdm/enroll (warning about prompt)
Change CA cert to payload type com.apple.security.root

(cherry picked from commit 0d8d092)
2016-10-25 17:21:32 +11:00
mosen
d56e06f992 Empty consent text in enroll profile was generating an invalid plist key. (#39)
Enrollment service now takes the TLS certificate path and provides a PKCS1 payload with the servers TLS certificate in order to trust it at enroll time.
2016-10-25 14:08:45 +11:00
mosen
58c44cd7f3 Feature/certificate expiry warnings (#29)
* 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

* Add log messages when the TLS certificate fails verification.

* Fix invalid return value.
Log when certificate cannot be parsed.

* MicroMDM will now exit with status code 1 if certificates are expired or invalid.
2016-10-25 14:08:29 +11:00
mosen
1a42fda576 Add new travis CI configuration (#38) 2016-10-25 14:07:58 +11:00
Victor Vrantchan
3552628379 Update missing time.Time from pointer to value fields. (#37)
Regressioin introduced in #34

Fixes #36
2016-10-13 10:07:35 -04:00
mosen
e4ab7e0b17 Hotfix/last check in (#34)
* Convert all time.Time pointers to value types.
Use UTC time when updating `last_checkin`.
Update `last_checkin` correctly on Authenticate, TokenUpdate, and query response.
Set database defaults to golangs zero value for time.Time which is `0001-01-01`.

* Add down migration for time defaults.
2016-10-12 16:20:48 +11:00
Victor Vrantchan
1cd3a459eb update deps (#32) 2016-10-11 23:28:09 -04:00
mosen
3991374503 Hotfix/enroll payloadscope (#31)
* 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

* Model is sent with Authenticate message so best to update it there without having to query DeviceInformation.

* Incorrect struct tags result in PayloadScope not being included in the mdm enroll profile output.
2016-10-12 12:07:52 +11:00
mosen
8c192d456d Feature/authenticate model update (#30)
* 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

* Model is sent with Authenticate message so best to update it there without having to query DeviceInformation.
2016-10-12 11:52:51 +11:00
Elliot Jordan
30b658f497 Clean up on the read me file (#27)
* Fix typo, clean trailing space

* Parentheses cleanup
2016-10-11 10:28:18 +11:00
Victor Vrantchan
25dd485b13 update dependencies to latest version (#26) 2016-10-07 10:41:39 -04:00
mosen
bfdbc77a3a Non plural packages (#25)
* 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

* Rename certificates to certficiate
Rename applications to application
2016-10-07 12:35:06 +11:00
mosen
66dc2beb7f Certificates statements (#24)
* 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

* Include certificate statement builders.
These are necessary to support the current revision of the installed_certificates package.
2016-10-07 12:26:05 +11:00
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