Commit graph

2714 commits

Author SHA1 Message Date
jianglai
fdda03eb53 Use local GoogleCredential in the nomulus tool
The scenarios in which the credential is used are:

1) Calls to Nomulus GAE HTTP endpoints.
2) Calls to Google APIs within the tool.
3) Calls to GAE APIs within the tool.

From now on the tool should not depend on ADCs created from gcloud any more (expect for beam pipeline deployments which need some more investigation as the dependency on ADC is not apparent). Using the nomulus tool requires running "nomulus login" first, but only once.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224165735
2018-12-05 16:06:19 -05:00
jianglai
5f9aad90fc Configure client id and client secret in the config file
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224158599
2018-12-05 16:04:08 -05:00
jianglai
6352b8a01a Use self-managed credential in remote api installer
RemoteApiOption has a package-private method that takes a Stream representing the content of a JSON and use a GoogleCredential created from it as its credential. This CL uses reflection to change the access modifier of that method in order to supply a credential stream that is self-managed. This is obviously not ideal and prone to breakage in case the getGoogleCredentialStream method is changed. Unfortunately upstream is not willing to make it public citing the reason that GoogleCredential.fromStream() (which getGoogleCredentialStream uses) is a @Beta annotated function (see https://groups.google.com[]forum/#!searchin/domain-registry-eng/remoteapioptions%7Csort:date/domain-registry-eng/Flsah6skszQ/CySZv2XEBwAJ). However this function is introduced 5 years ago as a public function (b857184bfa). I think at this point it is safe to assume that it is part of the widely used APIs and will not change without sufficient notice.

Note here that RemoteApiOptions creates its own copy of GoogleCredential to be used to call App Engine APIs locally, whereas communications to Nomulus endpoints use the Credential provided in AuthModule. Even though both credentials are created from the same client id, client secret and refresh token (the three elements needed to construct a GoogleCredential this way, see https://github.com/googleapis/google-api-java-client/blob/master/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleCredential.java#L842), their refreshes cycles are independent of each other. I verified that refreshing one of the credential does not invalidate the access token of the other credential, as long as it is not expired yet.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224156131
2018-12-05 16:02:28 -05:00
jianglai
aeedc427ad Remove the ability to download service account credentials
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224034254
2018-12-05 16:00:51 -05:00
jianglai
879c48b079 Use gradlew in Cloud Build
Also moved pushing tags to the private repo to the last step as we do not want
to tag the configs unless the build is successful.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223982622
2018-12-05 15:59:10 -05:00
mmuller
23ce24bafb Use gradlew in travis build.
Now that we're shipping gradlew, use it from travis.   This is the prescribed
approach in the travis docs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223976622
2018-12-05 15:57:35 -05:00
jianglai
e4733953d3 Update bazel version to 0.20.0
Also updated distroless base image to include the latest vulnerability fixes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223975505
2018-12-05 15:56:01 -05:00
jianglai
7ec9513f3f Check gradle wrapper in to VCS
The version of gradle used in compilation is now controlled by the gradle
wrapper and is centrally managed. This means that everyone will be using the
same version of gradle for build, including IC systems like Travis and Cloud
Build.

The Gradle version for this Gradle wrapper is v5.0.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223856122
2018-12-03 19:26:38 -05:00
guyben
a3a60075a0 Hide the edit/add buttons for fields the user can't update
Currently the /registrar-settings backend endpoint will fail to update any
OWNER fields that a non-OWNER tries to change.

However, the front-end (soy, js) still allow non-OWNERs to try and change
these fields (there's the "edit" or "add" button, and it only fails when you try to "save")

This CL changes the front-end to remove the ability for non-OWNERs to even try
and change these fields. However, it will still let them *view* these fields as
it has interesting and important information.

-------------------------------

In addition - it changes the webdriver tests to include the "edit buttons". Those were never tested before, and now we will test to see if they are indeed displayed or not.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223845883
2018-12-03 19:25:05 -05:00
mmuller
f980a25b32 Remove deprecated tags in appengine-web.xml
Remove the application and version tags and replace "module" with "service".
The old tags have been deprecated for ages, and they cause warnings when we
do gradle deployment/staging.

TESTED:
  Deployed to crash, everything still seemed to work to the extent that crash
  can be expected to, service variations still happened, all services got
  updated.  Minimal risk to the other environments.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223799777
2018-12-03 19:23:31 -05:00
mcilwain
c70a8867c6 Move more lifecycle test helper methods to base class
This also raises their access level so they can be called by other classes that
extend EppTestCase (which I'm writing in a follow-up CL).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223512618
2018-12-03 19:21:52 -05:00
jianglai
54b6770ade Make DownloadServiceAccountCredentialAction only accept internal auth
This temporarily disables the ability to download service account credentials. We'd like this to go in to next week's release so that we do not expose this functionality to users who otherwise do not have the ability to download the service account credential, while we research on a more secure solution.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223397754
2018-12-03 19:20:18 -05:00
mmuller
ec11eae699 Add App Engine Deploy to Gradle build
Add a first pass add Nomulus GAE deployment to our gradle build scripts.  This
attempt could stand some improvement.  In particular:

- It currently only deploys to crash, per discussion we will make the
  environment a parameter.
- This uses a different import mechanism from the other plugins (via a
  "buildscript" section) and it looks like the lint plugin is very similar.
  I'll experiment with getting it to work that way.
- There is a lot of redundancy in the deployment scripts for each module, and
  given that we have the full power of a general programming language it
  should be possible for us to reuse the common parts.

But that said, this is a pretty good first step and I wanted to put it out
there.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223366370
2018-12-03 19:18:44 -05:00
mcilwain
3eff20ceb5 Consolidate EPP lifecycle helper methods
I'm adding another EPP lifecycle test that will need to be in the tools package
because it has to call tools as part of the lifecycle. This commit consolidates
common functionality within the EppTestCase abstract base class (and increases
visibility) so that it can easily be referenced by more extending classes, even
ones in a different package.

This also explicitly loads the test files from the testdata directory collocated
with EppTestCase, so that new tests in other packages won't have to duplicate
lots of these same test files.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223365398
2018-12-03 19:17:08 -05:00
guyben
849ea0e0f3 Fix --content-type and --data inputs in curl command
content-type needs to be parsed (no automatic parsing from String)

data was splitting on commas, meaning --data="key=value1,value2" was sent to the server as "key=value1&value2"

NOTE - you'd expect there to already be a "do nothing splitter", right? But there isn't :/

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223346887
2018-12-03 19:15:33 -05:00
shicong
5d2bb892f3 Update lastEppUpdateTime and lastEppUpdateClientId when necessary
EppResource's lastEppUpdateTime and lastEppUpdateClientId need
to be updated whenever the domain is updated, renewed, deleted or
transfered.

This commit applied the change to the following domain EPP commands:

 - Update (already implemented)
 - Renew
 - Delete
 - Restore
 - Transfer request
 - Transfer approve
 - Transfer reject
 - Transfer cancel

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223344758
2018-12-03 19:13:55 -05:00
jianglai
b54227e938 Remove duplicate cloudDns config
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223342648
2018-12-03 19:12:20 -05:00
mcilwain
11da64bee2 Deny non-active registrars access to non-free EPP commands
Registrars that are PENDING or SUSPENDED should not have access to
EPP commands that cost money, as in either case it's not likely we'd
actually be able to get payment from said registrar. For this reason
we already prevented access to the domain create flow for non-active
registrars. This commit extends that to other commands that cost
money, including renewals, restores, and transfer requests.

Note that implicit autorenews will still occur for suspended
registrars, as in our point-in-time data model there's no good way
to prevent them. So when a registrar is suspended for non-payment,
the game plan is to get all of their domains transferred out to a
registrar that will pay as soon as possible.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223173677
2018-12-03 19:10:45 -05:00
guyben
dbdc69916a Account for GoogleJsonResponseException#getDetails returning null
Apparently, this can happen

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223163802
2018-12-03 19:09:11 -05:00
mcilwain
c2ee453745 Make the verify OT&E action more performant
As previously written, it loaded up all history entries into memory and then
processed them. This was OOMing for some registrars on sandbox who had performed
a large number of testing actions, most of them long OT&E was passed.

This commit changes the verify OT&E action to stream the history entries in
batches, ordered by when they were made, and then terminates once all tests have
passed. This prevents OOMing because only a single batch of history entries need
reside in memory at once.

This does necessitate the creation of a new composite Datastore index on
HistoryEntry, so we'll need to run the ResaveAllHistoryEntriesAction in sandbox
after this change is deployed before the new verify OT&E code will work.

Note that the "history viewer" is long dead, but that the pre-existing index
on HistoryEntries is still used for many other purposes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223163337
2018-12-03 19:07:36 -05:00
jianglai
4416601a1d Expose the functionality to decrypt given data using keyring
This allows us to provide the keyring a blob of encrypted data and a key name, and have it decrypt it for us.

Also fixed javadoc length in Keyring.java. It seems like it was using a 80-character length limit.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222995542
2018-12-03 19:05:59 -05:00
jianglai
0ed0bcc99f Add runtime dependencies to the tools target
These targets are removed in [] as they are not compile-time
dependencies. But they are needed at runtime by GetRoutingMapCommand to load
the specific classes to generate routing map for.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222916432
2018-12-03 19:04:24 -05:00
jianglai
a86d6588f3 Add an action to download encrypted service account credentials
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222902380
2018-12-03 19:02:50 -05:00
jianglai
886aa62d46 Expose encrypted data from the keyring
This makes it possible to request the encrypted data directly in application code. It will be used to download service account credential during "nomulus login".

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222847905
2018-12-03 19:01:15 -05:00
jianglai
4598c5f105 Remove unnecessary Dagger qualifier
The @JsonPayload qualifier is not used because the field are contrustor injected.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222829281
2018-12-03 18:59:40 -05:00
shicong
d20b83c820 Add option --non_live_versions to set_num_instances command
This commit introduced a new flag to enable SetNumInstancesCommand to
be able to set the number of instances for all non-live versions for
a given service or for all deployed services.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222826003
2018-12-03 18:58:05 -05:00
guyben
19b7a7b3ec Allow only OWNERs to change owner-related data on registrar console
The console will have 2 different "updatable things":
- only ADMINs (GAE-admins and users in the support G-Suite group) can change the things in the "admin settings" tab (currently just the allowed TLDs)
- only OWNERs can change things from the other tabs: WHOIS info, certificates, whitelisted IPs, contacts etc.

Also, all ADMINs are now OWNERS of "non-REAL" registrars. Meaning - we're only
preventing ADMINs from editing "REAL" registrars (usually in production).

Specifically, OTE registrars on sandbox are NOT "REAL", meaning ADMINS will
still be able to update them.

This only changes the backend (registrar-settings endpoint). As-is, the console
website will still make ADMINs *think* they can change everything, but if they
try - they will get an error.

Changing the frontend will happen in the next CL - because I want to get this
out this release cycle and getting JS reviewed takes a long time :(

TESTED=deployed to alpha, and saw I can't update fields even as admin on REAL
registrars, but could change it on non-REAL registrars. Also checked that I can
update the allowed TLDs on REAL registrars

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222698270
2018-12-03 18:56:28 -05:00
guyben
5f283ebd09 Use AuthenticatedRegistrarAccessor in EppConsoleAction
EppConsoleAction still "manually" checks access by going over the
RegistrarContacts. We need it to use AuthenticatedRegistrarAccessor just like
every other part of the registrar console.

We still need to remove the (now unneeded) login EPP sent by the console, but that's left for a followup CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222404208
2018-12-03 18:51:40 -05:00
jianglai
eca3461dec Add a build badge for gradle
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222315861
2018-12-03 18:50:05 -05:00
jianglai
a0aeec6f2f Update bazel version to 0.19.2
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222309479
2018-12-03 18:48:28 -05:00
jianglai
87f30f0870 Add .gcloudignore and cloudbuild.yaml to open source build
Forgot to do this when I exported... Will have to do another export after this CL is added.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222296851
2018-11-20 16:41:36 -05:00
guyben
274b7115d4 Block ability to remove allowed TLDs from the registrar console
This is a temporary measure until we implement access control for Support.

Once we implement access control, we will only block Support from removing TLDs
on production.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222180321
2018-11-20 16:03:06 -05:00
jianglai
f46f817f9e Create proxy Docker image with Gradle
This CL adds two ways to build an docker image with gradle:

1) Adds a :proxy:deployJar task that builds an uber jar that contains all runtime dependencies. The jar can then be add to a docker image by calling docker with the added Dockerfile. The base image for this image can be both distroless java or openjdk:alpine.

2) Uses the Gradle distribution plugin to build a distribution tar file that contains all dependencies (as separate jar files) and a run script that sets up the classpath before calling the main class. Then the docker application plugin can build a docker image (with the dockerBuildImage task) using the application tar file. This only works with openjdk:alpline base image as the distroless java image does not contain a shell and therefore the script created by the distribution plugin cannot be launched.

We may later decide to use one of the method and remove the other.

Also adds an outcast test pattern that caused the tests to be flaky.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222145192
2018-11-19 18:19:27 -05:00
jianglai
118367dc6b Move proxy to its separate project
It can be run directly by "gradle :proxy:run"

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222102849
2018-11-19 18:17:47 -05:00
jianglai
997b49f7ca Move util to its separate project
It will make it easier later to have the proxy project depend on it, rather
than on the entire core project

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222081994
2018-11-19 18:16:03 -05:00
jianglai
f7e95e1ff1 Refactor gradle build script
1. Updated nebula lint version to 10.3.1
2. Do not apply plugins in the root projects that are not needed.
3. Only do linting when a build is successful, so that build failure message are not flushed by linter warnings.
4. Added explicitly stated java source and target version.
5. Moved source sets set up to the root project so that it applies to all subprojects. Currently there is only "core", but we will add at least "proxy" and "util" later, both of which will use mostly the same source sets (but with additional inclusion rules to only build classes in a specific sub folder in the source tree). By putting the set up closure inside the subprojects block in the root script, it can be reused.
6. Rename maybe_runtime configuration to maybeRuntime, which is consistent with other camelCase configuration names like testCompile.
7. Added a runtime dependency of the JAXB API which is removed from Java SE as of version 11.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222081092
2018-11-19 18:14:09 -05:00
jianglai
02a23c6ca6 Remove unnecessary source sets
These source sets are not configured correctly (no classpaths for example) and
they subsequently cannot compile. The special tests are put into separate tasks that
run from the same source set (test).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=222080273
2018-11-19 18:12:12 -05:00
weiminyu
676fa422db Use proper external dependency references recognized by moe
This fixes kokoro build failure.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221830188
2018-11-16 17:03:50 -05:00
weiminyu
af21b0c32b Add a package to open source
Add {java,tests}/google/registry/export/datastore to open source.
This is part of the migration to Datastore Managed Import/Export
for backup.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221800709
2018-11-16 17:02:15 -05:00
shicong
36c6265980 Make BillingModule.OVERALL_INVOICE_PREFIX configurable
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221700223
2018-11-16 17:00:38 -05:00
mcilwain
45f63cbecf Fix failing email sending FOSS test
This is surprisingly difficult to fix correctly, so for now, just don't
worry about the content type.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221694745
2018-11-16 16:59:05 -05:00
jianglai
86007622f7 Remove proxy's dependency on config
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221666668
2018-11-16 16:57:30 -05:00
weiminyu
dee559baee Define multiple test suites under Gradle for better test performance
Tests are divided into three test suites without intra-suite conflicts.
This allows us to unset forkEvery=1 (4x improvement on my desktop) and
increase execution parallelism (additional 2x improvement on my desktop).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221656972
2018-11-16 16:55:55 -05:00
guyben
6586460f3e Move AuthenticatedRegistrarAccessor to request/auth/
It is starting to be used in more places than just ur/server/registrar. Even now it's used in the RDAP, and we are going to start using it for the registrar-xhr endpoint meaning it will be used in EPP flows as well.

Also logically - this is part of the request authentication.

While moving - we also refactor it to make it easier to use in tests. Instead of mocking, we will be able to create instances with arbitrary roles.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221645055
2018-11-16 16:54:21 -05:00
mcilwain
b317aab22f Clean up some areas in preparation for externalized codebase
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221454055
2018-11-16 16:51:11 -05:00
jianglai
c0239b0a07 Move YamlUtils to be under google.registry.util package
This makes it simpler to package google.registry.util as a separate project in
Gradle that can be depended upon by the proxy package. Currently the proxy
package depends on both google.registry.util and google.registry.config.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221450085
2018-11-14 12:00:45 -05:00
guyben
e51cf3e9c7 Change OTE "fake" address state to a valid value
Currently, OTE creates an invalid address "state", which doesn't pass validation when trying to update it on the console.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221372006
2018-11-14 11:59:04 -05:00
weiminyu
75add42a1b Restore original System Properties after tests
Many registry tools tests modify system properties but do not
restore them to original state. These tests must be isolated
from each other and cannot share the same test execution process.

This has a huge impact on test performance under Gradle, which
seems to have higher process startup overhead. Current Gradle
test config has to set 'forEvery' to 1, i.e., every test class
must be run in a freshly started process.

This change significantly reduces the number of tests that need
isolation, making it easier to optimize test config for the
remaining tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221350284
2018-11-14 11:57:23 -05:00
jianglai
9fa2a84c35 Replace iteration over depsets with an explicit .to_list() call
The old pattern did an implicit iteration over a depset which will be forbidden in the future since it is potentially expensive. The new to_list() call is still expensive but it will be more visible.

LSC: []
Tested:
    TAP --sample for global presubmit queue
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221266626
2018-11-14 11:55:43 -05:00
guyben
4a31232423 Fix Kokoro build broken by []
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=221097556
2018-11-12 14:51:40 -05:00