Skip to content

Commit

Permalink
Merge pull request #6836 from TheThingsNetwork/issue/6567-remove-cont…
Browse files Browse the repository at this point in the history
…act-info-validation

Remove `contact_info` from validation process
  • Loading branch information
nicholaspcr authored Jan 22, 2024
2 parents ff13ef9 + e96b7ec commit 7168af5
Show file tree
Hide file tree
Showing 34 changed files with 2,654 additions and 53 deletions.
4 changes: 4 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ lint:
- ttn/lorawan/v3/contact_info.proto
- ttn/lorawan/v3/deviceclaimingserver.proto
- ttn/lorawan/v3/devicerepository.proto
- ttn/lorawan/v3/email_validation.proto
- ttn/lorawan/v3/end_device_services.proto
- ttn/lorawan/v3/gateway_services.proto
- ttn/lorawan/v3/gatewayserver.proto
Expand All @@ -88,6 +89,7 @@ lint:
- ttn/lorawan/v3/contact_info.proto
- ttn/lorawan/v3/deviceclaimingserver.proto
- ttn/lorawan/v3/devicerepository.proto
- ttn/lorawan/v3/email_validation.proto
- ttn/lorawan/v3/end_device_services.proto
- ttn/lorawan/v3/events.proto
- ttn/lorawan/v3/gateway_services.proto
Expand All @@ -112,6 +114,7 @@ lint:
- ttn/lorawan/v3/contact_info.proto
- ttn/lorawan/v3/deviceclaimingserver.proto
- ttn/lorawan/v3/devicerepository.proto
- ttn/lorawan/v3/email_validation.proto
- ttn/lorawan/v3/end_device_services.proto
- ttn/lorawan/v3/events.proto
- ttn/lorawan/v3/gateway_services.proto
Expand All @@ -138,6 +141,7 @@ lint:
- ttn/lorawan/v3/contact_info.proto
- ttn/lorawan/v3/deviceclaimingserver.proto
- ttn/lorawan/v3/devicerepository.proto
- ttn/lorawan/v3/email_validation.proto
- ttn/lorawan/v3/end_device_services.proto
- ttn/lorawan/v3/events.proto
- ttn/lorawan/v3/gateway_services.proto
Expand Down
55 changes: 55 additions & 0 deletions api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@
- [Service `DeviceRepository`](#ttn.lorawan.v3.DeviceRepository)
- [File `ttn/lorawan/v3/email_messages.proto`](#ttn/lorawan/v3/email_messages.proto)
- [Message `CreateClientEmailMessage`](#ttn.lorawan.v3.CreateClientEmailMessage)
- [File `ttn/lorawan/v3/email_validation.proto`](#ttn/lorawan/v3/email_validation.proto)
- [Message `EmailValidation`](#ttn.lorawan.v3.EmailValidation)
- [Message `ValidateEmailRequest`](#ttn.lorawan.v3.ValidateEmailRequest)
- [Service `EmailValidationRegistry`](#ttn.lorawan.v3.EmailValidationRegistry)
- [File `ttn/lorawan/v3/end_device.proto`](#ttn/lorawan/v3/end_device.proto)
- [Message `ADRSettings`](#ttn.lorawan.v3.ADRSettings)
- [Message `ADRSettings.DisabledMode`](#ttn.lorawan.v3.ADRSettings.DisabledMode)
Expand Down Expand Up @@ -3624,6 +3628,57 @@ CreateClientEmailMessage is used as a wrapper for handling the email regarding t
| `create_client_request` | [`CreateClientRequest`](#ttn.lorawan.v3.CreateClientRequest) | | |
| `api_key` | [`APIKey`](#ttn.lorawan.v3.APIKey) | | |

## <a name="ttn/lorawan/v3/email_validation.proto">File `ttn/lorawan/v3/email_validation.proto`</a>

### <a name="ttn.lorawan.v3.EmailValidation">Message `EmailValidation`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [`string`](#string) | | |
| `token` | [`string`](#string) | | |
| `address` | [`string`](#string) | | |
| `created_at` | [`google.protobuf.Timestamp`](#google.protobuf.Timestamp) | | |
| `expires_at` | [`google.protobuf.Timestamp`](#google.protobuf.Timestamp) | | |
| `updated_at` | [`google.protobuf.Timestamp`](#google.protobuf.Timestamp) | | |

#### Field Rules

| Field | Validations |
| ----- | ----------- |
| `id` | <p>`string.min_len`: `1`</p><p>`string.max_len`: `64`</p> |
| `token` | <p>`string.min_len`: `1`</p><p>`string.max_len`: `64`</p> |
| `address` | <p>`string.email`: `true`</p> |

### <a name="ttn.lorawan.v3.ValidateEmailRequest">Message `ValidateEmailRequest`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [`string`](#string) | | |
| `token` | [`string`](#string) | | |

#### Field Rules

| Field | Validations |
| ----- | ----------- |
| `id` | <p>`string.min_len`: `1`</p><p>`string.max_len`: `64`</p> |
| `token` | <p>`string.min_len`: `1`</p><p>`string.max_len`: `64`</p> |

### <a name="ttn.lorawan.v3.EmailValidationRegistry">Service `EmailValidationRegistry`</a>

The EmailValidationRegistry service, exposed by the Identity Server, is used for validating an user's primary email.

| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| `RequestValidation` | [`UserIdentifiers`](#ttn.lorawan.v3.UserIdentifiers) | [`EmailValidation`](#ttn.lorawan.v3.EmailValidation) | Request validation for the non-validated contact info for the given entity. |
| `Validate` | [`ValidateEmailRequest`](#ttn.lorawan.v3.ValidateEmailRequest) | [`.google.protobuf.Empty`](#google.protobuf.Empty) | Validate confirms a contact info validation. |

#### HTTP bindings

| Method Name | Method | Pattern | Body |
| ----------- | ------ | ------- | ---- |
| `RequestValidation` | `POST` | `/api/v3/email/validation` | `*` |
| `Validate` | `PATCH` | `/api/v3/email/validation` | `*` |

## <a name="ttn/lorawan/v3/end_device.proto">File `ttn/lorawan/v3/end_device.proto`</a>

### <a name="ttn.lorawan.v3.ADRSettings">Message `ADRSettings`</a>
Expand Down
105 changes: 105 additions & 0 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
{
"name": "DeviceRepository"
},
{
"name": "EmailValidationRegistry"
},
{
"name": "EndDeviceRegistry"
},
Expand Down Expand Up @@ -6470,6 +6473,71 @@
]
}
},
"/email/validation": {
"post": {
"summary": "Request validation for the non-validated contact info for the given entity.",
"operationId": "EmailValidationRegistry_RequestValidation",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3EmailValidation"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3UserIdentifiers"
}
}
],
"tags": [
"EmailValidationRegistry"
]
},
"patch": {
"summary": "Validate confirms a contact info validation.",
"operationId": "EmailValidationRegistry_Validate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"type": "object",
"properties": {}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3ValidateEmailRequest"
}
}
],
"tags": [
"EmailValidationRegistry"
]
}
},
"/events": {
"post": {
"summary": "Stream live events, optionally with a tail of historical events (depending on server support and retention policy).\nEvents may arrive out-of-order.",
Expand Down Expand Up @@ -20094,6 +20162,32 @@
"default": "DOWNLINK_PATH_CONSTRAINT_NONE",
"description": " - DOWNLINK_PATH_CONSTRAINT_NONE: Indicates that the gateway can be selected for downlink without constraints by the Network Server.\n - DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER: Indicates that the gateway can be selected for downlink only if no other or better gateway can be selected.\n - DOWNLINK_PATH_CONSTRAINT_NEVER: Indicates that this gateway will never be selected for downlink, even if that results in no available downlink path."
},
"v3EmailValidation": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"token": {
"type": "string"
},
"address": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"expires_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"v3EncodeDownlinkResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -26225,6 +26319,17 @@
}
}
},
"v3ValidateEmailRequest": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"token": {
"type": "string"
}
}
},
"v3ZeroableFrequencyValue": {
"type": "object",
"properties": {
Expand Down
69 changes: 69 additions & 0 deletions api/ttn/lorawan/v3/email_validation.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright © 2023 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package ttn.lorawan.v3;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "ttn/lorawan/v3/identifiers.proto";
import "validate/validate.proto";

option go_package = "go.thethings.network/lorawan-stack/v3/pkg/ttnpb";

message EmailValidation {
string id = 1 [(validate.rules).string = {
max_len: 64,
min_len: 1
}];
string token = 2 [(validate.rules).string = {
max_len: 64,
min_len: 1
}];
string address = 3 [(validate.rules).string.email = true];
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp expires_at = 5;
google.protobuf.Timestamp updated_at = 6;
}

message ValidateEmailRequest {
string id = 1 [(validate.rules).string = {
max_len: 64,
min_len: 1
}];
string token = 2 [(validate.rules).string = {
max_len: 64,
min_len: 1
}];
}

// The EmailValidationRegistry service, exposed by the Identity Server, is used for validating an user's primary email.
service EmailValidationRegistry {
// Request validation for the non-validated contact info for the given entity.
rpc RequestValidation(UserIdentifiers) returns (EmailValidation) {
option (google.api.http) = {
post: "/email/validation"
body: "*"
};
}
// Validate confirms a contact info validation.
rpc Validate(ValidateEmailRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
patch: "/email/validation"
body: "*"
};
}
}
13 changes: 6 additions & 7 deletions cmd/ttn-lw-cli/commands/contact_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ func updateContactInfo(entityID *ttnpb.EntityIdentifiers, updater func([]*ttnpb.
var (
errContactInfoExists = errors.DefineAlreadyExists("contact_info_exists", "contact info already exists")
errMatchingContactInfoNotFound = errors.DefineAlreadyExists("contact_info_not_found", "matching contact info not found")
errNoValidationReference = errors.DefineInvalidArgument("no_validation_reference", "no validation reference set")
errNoValidationToken = errors.DefineInvalidArgument("no_validation_token", "no validation token set")
)

func contactInfoCommands(entity string, getID func(cmd *cobra.Command, args []string) (*ttnpb.EntityIdentifiers, error)) *cobra.Command {
Expand Down Expand Up @@ -228,8 +226,9 @@ func contactInfoCommands(entity string, getID func(cmd *cobra.Command, args []st
},
}
requestValidation := &cobra.Command{
Use: fmt.Sprintf("request-validation [%s-id]", entity),
Short: "Request validation for entity contact info",
Use: fmt.Sprintf("request-validation [%s-id]", entity),
Short: "Request validation for entity contact info (DEPRECATED. Use `user email-validation request` instead.",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
id, err := getID(cmd, args)
if err != nil {
Expand All @@ -247,9 +246,9 @@ func contactInfoCommands(entity string, getID func(cmd *cobra.Command, args []st
},
}
validate := &cobra.Command{
Use: "validate [reference] [token]",
Short: "Validate contact info",
Long: "Validate contact info by providing the reference and the validation token that you received",
Use: "validate [reference] [token]",
Short: "Validate contact info (DEPRECATED. Use `user email-validation validate` instead.",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
reference, _ := cmd.Flags().GetString("reference")
token, _ := cmd.Flags().GetString("token")
Expand Down
Loading

0 comments on commit 7168af5

Please sign in to comment.