This updates the command to our emergent standards. It also enables
using a separate config file for a config kms, which allows non-string
values to be encrypted.
This allowed some nice cleanup as well.
This is useful if you, for instance, want Terraform to be 100%
responsible for creation of resources (outside of the static ones that
cannot be removed or modified, like u_anon). This will mean using the
recovery mechanism for initial setup, but that isn't an issue once TF
supports that :-)
* Encrypt tokens on the way out and decrypt on the way in
This isn't a security feature related to tokens specifically; it's so
that we can discard cryptographically bad tokens before we ever hit the
DB. This way we can't pass through a DDoS to the database due to
fetching obviously invalid token values.
I'm using base58 to encode the resulting value as there aren't great
base62 options, and allowing base64 / and + values can hamper usability
by creating copying/highlighting breaks.
* Allow updating accounts (not username or pw).
* Updating new field names to LoginName.
* Adding creation with password test.
* Fixing documentation for WithLoginName
Even if you made a custom formatter for gorm, it would blithely println
anything returned, including nils, resulting in lots of new lines when
we were ignoring output. This also creates a custom logger that doesn't
do anything when newlines are found.
This can be used in tests to get access to a controller that behaves
just like a dev controller but doesn't require the normal Command bits
(UI, etc).
This can be enhanced over time as needed; for now it's pretty simple but
it's good enough to be used for API tests. A simple project create/read
API test is added as well, which serves to show the programmatic model
(as well as test those functions at the API level).
These changes create a dev org in the database on startup.
They also plumb through a dev-org-id flag that allows specifying a chosen org ID in dev mode.
The logic will allow us to let people specify a default org ID in the config file too, although currently that's not enabled.
Several other improvements were made as well:
* Consolidation of some code from across the server commands
* Plumbing shutdownch through so we can use it for canceling contexts during startup
This was copied from Vault code but shouldn't be necessary any more as a
change in hclog a while back meant that derived loggers share the log
level of the parent.
* Rename FriendlyName to Name
* Standardize on connection parameters for the server being addr
This syncs up WATCHTOWER_ADDR and -addr (formerly -address) and frees up
-address to be used in resources (which it is).
* Add description fields
Since client code uses the package name as a prefix when referring to
the package contents, the names for those contents need not repeat the
package name.
- Rename base.BaseCommand to base.Command
- Rename base.BaseServer to base.Server
- Rename config.DevConfig() to config.Dev()
- Rename config.LoadConfigFile() to config.LoadFile()
- Rename config.NewConfig() to config.New()
- Rename config.ParseConfig() to config.Parse()
- Rename controller.ControllerCommand to controller.Command
- Rename controller.NewController() to controller.New()
- Rename dev.DevCommand to dev.Command
- Rename listener.ListenerFactory to listener.Factory
- Rename listener.NewListener() to listener.New()
- Rename version.GetVersion() to version.Get()
- Rename version.VersionInfo to version.Info
See:
- https://golang.org/doc/effective_go.html#package-names
- https://blog.golang.org/package-names#TOC_3.
- https://github.com/golang/go/wiki/CodeReviewComments#package-names