Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: add crud support for keys #84

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1";
Expand Down Expand Up @@ -54,6 +56,43 @@ service RecaptchaEnterpriseServiceV1Beta1 {
};
option (google.api.method_signature) = "name,annotation";
}

// Creates a new reCAPTCHA Enterprise key.
rpc CreateKey(CreateKeyRequest) returns (Key) {
option (google.api.http) = {
post: "/v1beta1/{parent=projects/*}/keys"
body: "key"
};
}

// Returns the list of all keys that belong to a project.
rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) {
option (google.api.http) = {
get: "/v1beta1/{parent=projects/*}/keys"
};
}

// Returns the specified key.
rpc GetKey(GetKeyRequest) returns (Key) {
option (google.api.http) = {
get: "/v1beta1/{name=projects/*/keys/*}"
};
}

// Updates the specified key.
rpc UpdateKey(UpdateKeyRequest) returns (Key) {
option (google.api.http) = {
patch: "/v1beta1/{key.name=projects/*/keys/*}"
body: "key"
};
}

// Deletes the specified key.
rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1beta1/{name=projects/*/keys/*}"
};
}
}

// The create assessment request message.
Expand Down Expand Up @@ -154,13 +193,25 @@ message Assessment {
}

message Event {
// Required. The user response token provided by the reCAPTCHA client-side integration
// Optional. The user response token provided by the reCAPTCHA client-side integration
// on your site.
string token = 1 [(google.api.field_behavior) = REQUIRED];
string token = 1 [(google.api.field_behavior) = OPTIONAL];

// Required. The site key that was used to invoke reCAPTCHA on your site and generate
// Optional. The site key that was used to invoke reCAPTCHA on your site and generate
// the token.
string site_key = 2 [(google.api.field_behavior) = REQUIRED];
string site_key = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. The user agent present in the request from the user's device related to
// this event.
string user_agent = 3 [(google.api.field_behavior) = OPTIONAL];

// Optional. The IP address in the request from the user's device related to this event.
string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL];

// Optional. The expected action for this type of event. This should be the same action
// provided at token generation time on client-side platforms already
// integrated with recaptcha enterprise.
string expected_action = 5 [(google.api.field_behavior) = OPTIONAL];
}

message TokenProperties {
Expand Down Expand Up @@ -207,3 +258,184 @@ message TokenProperties {
// Action name provided at token generation.
string action = 5;
}

// The create key request message.
message CreateKeyRequest {
// Required. The name of the project in which the key will be created, in the
// format "projects/{project_number}".
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "cloudresourcemanager.googleapis.com/Project"
}
];

// Required. Information to create a reCAPTCHA Enterprise key.
Key key = 2 [(google.api.field_behavior) = REQUIRED];
}

// The list keys request message.
message ListKeysRequest {
// Required. The name of the project that contains the keys that will be
// listed, in the format "projects/{project_number}".
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "cloudresourcemanager.googleapis.com/Project"
}
];

// Optional. The maximum number of keys to return. Default is 10. Max limit is
// 1000.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. The next_page_token value returned from a previous.
// ListKeysRequest, if any.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response to request to list keys in a project.
message ListKeysResponse {
// Key details.
repeated Key keys = 1;

// Token to retrieve the next page of results. It is set to empty if no keys
// remain in results.
string next_page_token = 2;
}

// The get key request message.
message GetKeyRequest {
// Required. The name of the requested key, in the format
// "projects/{project_number}/keys/{key_id}".
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recaptchaenterprise.googleapis.com/Key"
}
];
}

// The update key request message.
message UpdateKeyRequest {
// Required. The key to update.
Key key = 1 [(google.api.field_behavior) = REQUIRED];

// Optional. The mask to control which field of the key get updated. If the mask is not
// present, all fields will be updated.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
}

// The delete key request message.
message DeleteKeyRequest {
// Required. The name of the key to be deleted, in the format
// "projects/{project_number}/keys/{key_id}".
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recaptchaenterprise.googleapis.com/Key"
}
];
}

// A key used to identify and configure applications (web and/or mobile) that
// use reCAPTCHA Enterprise.
message Key {
option (google.api.resource) = {
type: "recaptchaenterprise.googleapis.com/Key"
pattern: "projects/{project}/keys/{key}"
};

// The resource name for the Key in the format
// "projects/{project_number}/keys/{key_id}".
string name = 1;

// Human-readable display name of this key. Modifiable by user.
string display_name = 2;

// Platform specific settings for this key. The key can only be used on one
// platform, the one it has settings for.
oneof platform_settings {
// Settings for keys that can be used by websites.
WebKeySettings web_settings = 3;

// Settings for keys that can be used by Android apps.
AndroidKeySettings android_settings = 4;

// Settings for keys that can be used by iOS apps.
IOSKeySettings ios_settings = 5;
}
}

// Settings specific to keys that can be used by websites.
message WebKeySettings {
// Enum that represents the integration types for web keys.
enum IntegrationType {
// Default type that indicates this enum hasn't been specified. This is not
// a valid IntegrationType, one of the other types must be specified
// instead.
INTEGRATION_TYPE_UNSPECIFIED = 0;

// Only used to produce scores. It doesn't display the "I'm not a robot"
// checkbox and never shows captcha challenges.
SCORE_ONLY = 1;

// Displays the "I'm not a robot" checkbox and may show captcha challenges
// after it is checked.
CHECKBOX_CHALLENGE = 2;

// Doesn't display the "I'm not a robot" checkbox, but may show captcha
// challenges after risk analysis.
INVISIBLE_CHALLENGE = 3;
}

// Enum that represents the possible challenge frequency and difficulty
// configurations for a web key.
enum ChallengeSecurityPreference {
// Default type that indicates this enum hasn't been specified.
CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED = 0;

// Key tends to show fewer and easier challenges.
USABILITY = 1;

// Key tends to show balanced (in amount and difficulty) challenges.
BALANCED = 2;

// Key tends to show more and harder challenges.
SECURITY = 3;
}

// Whether allowed_domains is enforced or not.
bool enforce_allowed_domains = 3;

// Domains or subdomains of websites allowed to use the key. All subdomains
// of an allowed domain are automatically allowed. A valid domain requires a
// host and must not include any path, port, query or fragment.
// Examples: 'example.com' or 'subdomain.example.com'
repeated string allowed_domains = 1;

// Whether this key can be used on AMP (Accelerated Mobile Pages) websites.
bool allow_amp_traffic = 2;

// Required. Describes how this key is integrated with the website.
IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED];

// Settings for the frequency and difficulty at which this key triggers
// captcha challenges. This should only be specified for IntegrationTypes
// CHECKBOX_CHALLENGE and INVISIBLE_CHALLENGE.
ChallengeSecurityPreference challenge_security_preference = 5;
}

// Settings specific to keys that can be used by Android apps.
message AndroidKeySettings {
// Android package names of apps allowed to use the key.
// Example: 'com.companyname.appname'
repeated string allowed_package_names = 1;
}

// Settings specific to keys that can be used by iOS apps.
message IOSKeySettings {
// iOS bundle ids of apps allowed to use the key.
// Example: 'com.companyname.productname.appname'
repeated string allowed_bundle_ids = 1;
}
Loading