Commit Graph

56 Commits

Author SHA1 Message Date
HuKeping 9cc5a7d9ea Package replace
Replace the use of the "assert" package with the "require" package.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-16 16:21:35 +08:00
Ying Li e25746dac3 Use a CacheControlHandler that wraps other handlers instead
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-14 17:19:13 -07:00
HuKeping 7e1a9947de Tiny refactor
If we can use a simple name for the local variable.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-11 14:11:27 +08:00
Ying Li 77cc1a0028 Add tests for the TLS command line flags in notary.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-04 17:24:26 -08:00
Ying Li 60ee270a2b Use docker/go-connections/tlsconfig to set up TLS for notary client/server/signer
This adds some command line flags and configuration for the notary client:
--tlscacert
--tlscert
--tlskey

This enables the notary client to do mutual authentication with the notary server.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-04 14:02:35 -08:00
Ying Li c77bbee0ef Merge pull request #351 from cyli/better-validation-errors
Propagate error validations from server to client
2015-12-10 21:29:57 -08:00
Ying Li 4208945fc1 Move the notary errors HTTP errors into the server package.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 11:22:49 -08:00
Miloslav Trmač d5c080ae9c Add cryptoservice.GenerateTestingCertificate
Various tests have been calling trustmanager.NewCertificate and
open-coding most of cryptoservice.GenerateCertificate.  So, add
cryptoservice.GenerateTestingCertificate.  It differs only by using
crypto.Signer instead of data.PrivateKey because the tests
have a crypto.Signer more frequently available, and converting
from data.PrivateKey to crypto.Signer is easier than the other way.

This will make it easier to add policy parameters which the tests don't
care about to trustmanager.NewCertificate and
cryptoservice.GenerateCertificate in the future.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
HuKeping bfe7316de9 Add a function to parse viper
None of these `filename`, `ext` or `configPath` should be in `main`,
they are all just for creating a instance of Viper and then nothing.
Do it in a separate function will make the function `main` more readable.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-12-09 09:17:24 +08:00
Ying Li a94a47651f Adds specific memory backend support to server and signer.
The server already supported a memory backend, but now it must be
specified, rather than just being a fallback if no storage is
specified.  This also adds a signer backend to signer, which
previously required a MySQL backend.

Thanks @endophage for the excellent suggestion!

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-30 10:58:57 -08:00
Ying Li f1bd28caf4 The TLS certificates are now relative to the config file used.
Previously, if a relative path was provided, it was relative to the
current working directory to wherever the binaries were run.  Now
it is relative to whatever config file was used.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-30 10:58:57 -08:00
Ying Li b25f8546f8 Ensure that environment variables can override config file entries.
Also support parameterized allowed backends when parsing for
storage backends, so that a DB backend can be tested.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-30 10:58:57 -08:00
Ying Li b1fdea5b56 Add shared config file parsing to the utils package.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-30 10:58:57 -08:00
Miloslav Trmač 40bfc3f890 Don't use elliptic.P224()
This curve is not available on Fedora and RHEL systems, so removing the
reference allows tests to pass there.  Vast majority of the
curve-specific work is done in the golang crypto/elliptic package, so
this does not weaken the tests noticeably.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-10-30 20:44:05 +01:00
David Lawrence 2833a88292 adding gotuf to notary
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-10-27 16:36:06 -07:00
Ying Li 15c3bbeb9c Remove explicit test for parsing garbage in certs.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-23 20:55:59 -07:00
Ying Li 09dc607bef Read multiple CA certs from a single PEM file - thanks @mtrmac!
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-23 15:56:47 -07:00
Ying Li 61f9f84254 Use configuration option structures to set up client TLS and server TLS.
Test for if client cert is passed without a client key and vice versa.
Fail in ConfigureClientTLS if only one of client cert/key is passed.
Lint fixes.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-21 18:43:33 -07:00
Ying Li 412e0facc8 Explicitly check the skip tls verify boolean in notary client
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-21 10:38:48 -07:00
Ying Li 5cdb46a9da Accept the same ciphersuites in the client and server as docker.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:31:18 -07:00
Ying Li fb81aaed10 Add test for if the client CA dir is empty
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:31:18 -07:00
Ying Li fb1013b997 Add servername to the client TLS config, and use it to build notary-server's
TLS connection to notary-signer.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:29:54 -07:00
Ying Li b399783eee Slight refactoring of ConfigureServerTLS and added a ConfigureClientTLS
as well.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:29:54 -07:00
Ying Li 7356dfd273 Change ConfigServerTLS to take a client CA directory instead of certs
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:29:54 -07:00
Ying Li 77dc081ead Add a utility which generates a tls configuration for you given the
requisite certs.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-19 17:29:54 -07:00
Aaron Lehmann 234c510096 Don't blindly overwrite ctx with result of Authorized
If Authorized returns an error, it returns nil for ctx. This means the
deferred function will dereference a nil pointer.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-08-17 15:42:32 -07:00
Aaron Lehmann a833f055e2 Change logging to use contexts effectively
Use the github.com/docker/distribution/context package to get a logger
that adds a unique ID and useful information about each HTTP request.

Use this logger in HTTP handlers instead of using logrus or the log
package directly.

Remove [Notary Server] and [Notary Signer] prefixes from log messages.

The distribution/context package was already vendored, so there are no
Godeps changes necessary.

Sample output:

    notaryserver_1 | time="2015-07-31T23:02:01Z" level=debug msg="retrieving timestamp key for docker.com/docker"
    notarysigner_1 | time="2015-07-31T23:02:01Z" level=debug msg="generated ECDSA key with keyID: ea89e7dc49a13feab1e5ed349760b148c3c6ebd86968b2bc6cb0d003a8b79f78"
    notarysigner_1 | time="2015-07-31T23:02:01Z" level=debug msg="generated new ecdsa key for role:  and keyID: ea89e7dc49a13feab1e5ed349760b148c3c6ebd86968b2bc6cb0d003a8b79f78"
    notarysigner_1 | time="2015-07-31T23:02:01Z" level=info msg="CreateKey: Created KeyID ea89e7dc49a13feab1e5ed349760b148c3c6ebd86968b2bc6cb0d003a8b79f78"
    notaryserver_1 | time="2015-07-31T23:02:01Z" level=debug msg="Creating new timestamp key for docker.com/docker. With algo: ecdsa"
    notaryserver_1 | time="2015-07-31T23:02:01Z" level=debug msg="Inserting timestamp key for docker.com/docker"
    notaryserver_1 | time="2015-07-31T23:02:01Z" level=debug msg="200 GET timestamp key" docker.com/docker=gun http.request.host="192.168.99.100:4443" http.request.id=a720da02-4312-48ae-b122-6d4bce9d3b20 http.request.method=GET http.request.remoteaddr="192.168.99.1:58178" http.request.uri="/v2/docker.com/docker/_trust/tuf/timestamp.key" http.request.useragent="Go 1.1 package http"
    notaryserver_1 | time="2015-07-31T23:02:01Z" level=info msg="response completed" http.request.host="192.168.99.100:4443" http.request.id=a720da02-4312-48ae-b122-6d4bce9d3b20 http.request.method=GET http.request.remoteaddr="192.168.99.1:58178" http.request.uri="/v2/docker.com/docker/_trust/tuf/timestamp.key" http.request.useragent="Go 1.1 package http" http.response.duration=29.703624ms http.response.status=200 http.response.written=181

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-31 16:06:56 -07:00
David Lawrence efda5034d9 can't be so restrictive on notary's GUN matching in URLs
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-31 14:38:24 -07:00
Aaron Lehmann 02dfdaf197 Use correct regular expression for repository names in HTTP handlers
Import github.com/docker/distribution/registry/api/v2 to share the
regexps that the registry API uses.

Remove ErrUnauthorized in errors package, since it conflicts with one
defined in v2.

Fixes #92

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-27 14:51:59 -07:00
David Lawrence b561f347ed updating errors to use distribution's errcode package
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-17 18:02:56 -07:00
Derek McGowan e4bb29a669 Fix access controller resource type
The token server returns tokens with the type as "repository" not "repo".

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-07-13 16:22:05 -07:00
Diogo Mónica 935b9a9366 Merge pull request #47 from docker/cryptoservice-refactor
Refactor crypto service
2015-07-13 15:29:59 -07:00
Aaron Lehmann e4704f9729 Update notary for removal of signed.Signer
We now deal with CryptoServices directly instead of passing around
Signers.

UnlockedSigner becomes UnlockedCryptoService because it no longer
contains a Signer.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-13 15:18:02 -07:00
David Lawrence 12dd2c2273 challenge.ServeHTTP doesn't set Unauthorized status code
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-13 14:21:14 -07:00
David Lawrence da59198191 adding htpasswd auth to support the same set of mechanisms as distribution
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-13 14:17:24 -07:00
David Lawrence 89379a728c adding timestamping and some general cleanup
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-03 15:38:09 -07:00
Nathan McCauley 518d0a2702 Notary Server in server log messages
Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
2015-06-19 11:17:06 -07:00
Nathan McCauley e46a95227c rename vetinari to notary
Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
2015-06-19 11:01:19 -07:00
David Lawrence 6805f290f0 all vetinari tests pass 2015-06-17 11:28:59 -07:00
David Lawrence 801dd397ff runs with basic setup for demo 2015-06-16 12:17:40 -07:00
David Lawrence cc0782d3d2 rewriting imports to 'gotuf', adding config to set log level, making
restart/shutdown cleanup connections after timeout, updating godeps
2015-06-11 16:30:25 -07:00
David Lawrence 6055569d48 fixing lint 2015-04-24 11:23:59 -07:00
David Lawrence 929828ba52 token authorizer with passing tests 2015-04-24 11:12:05 -07:00
David Lawrence 9df0215cfb making lint happy 2015-04-21 15:33:40 -07:00
David Lawrence 70b749bb46 renaming interfaces to be more go-like now that arch is settling down 2015-04-21 15:01:09 -07:00
David Lawrence d287dd9974 improving scoping by not exporting some things 2015-04-21 11:38:57 -07:00
David Lawrence 2ec64fcec6 adding server tests 2015-04-20 16:09:44 -07:00
David Lawrence c7747ead44 fixing tests 2015-04-20 12:15:33 -07:00
David Lawrence 5d9647b307 lint fix 2015-04-20 12:10:50 -07:00
David Lawrence 52505d36e1 cleanup work and updating godeps 2015-04-20 11:30:58 -07:00