Skip to content

Commit

Permalink
Add turnstile site key to captcha required response
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Nov 17, 2023
1 parent a8f462a commit 4f459b3
Show file tree
Hide file tree
Showing 33 changed files with 179 additions and 226 deletions.
9 changes: 0 additions & 9 deletions errors/captcha/captcha-origin-not-allowed.md

This file was deleted.

6 changes: 1 addition & 5 deletions fern/definition/cloud/version/matchmaker/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ types:
CaptchaTurnstile:
docs: Turnstile captcha configuration.
properties:
domains: map<string, CaptchaTurnstileDomain>

CaptchaTurnstileDomain:
docs: Turnstile domain configuration.
properties:
site_key: string
secret_key: string

NetworkMode:
Expand Down
13 changes: 3 additions & 10 deletions gen/openapi/external/spec/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9741,19 +9741,12 @@ components:
type: object
description: Turnstile captcha configuration.
properties:
domains:
type: object
additionalProperties:
$ref: '#/components/schemas/CloudVersionMatchmakerCaptchaTurnstileDomain'
required:
- domains
CloudVersionMatchmakerCaptchaTurnstileDomain:
type: object
description: Turnstile domain configuration.
properties:
site_key:
type: string
secret_key:
type: string
required:
- site_key
- secret_key
CloudVersionMatchmakerNetworkMode:
type: string
Expand Down
2 changes: 0 additions & 2 deletions gen/openapi/internal/rust/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ docs/CloudVersionMatchmakerCaptcha.md
docs/CloudVersionMatchmakerCaptchaHcaptcha.md
docs/CloudVersionMatchmakerCaptchaHcaptchaLevel.md
docs/CloudVersionMatchmakerCaptchaTurnstile.md
docs/CloudVersionMatchmakerCaptchaTurnstileDomain.md
docs/CloudVersionMatchmakerConfig.md
docs/CloudVersionMatchmakerGameMode.md
docs/CloudVersionMatchmakerGameModeActions.md
Expand Down Expand Up @@ -495,7 +494,6 @@ src/models/cloud_version_matchmaker_captcha.rs
src/models/cloud_version_matchmaker_captcha_hcaptcha.rs
src/models/cloud_version_matchmaker_captcha_hcaptcha_level.rs
src/models/cloud_version_matchmaker_captcha_turnstile.rs
src/models/cloud_version_matchmaker_captcha_turnstile_domain.rs
src/models/cloud_version_matchmaker_config.rs
src/models/cloud_version_matchmaker_game_mode.rs
src/models/cloud_version_matchmaker_game_mode_actions.rs
Expand Down
1 change: 0 additions & 1 deletion gen/openapi/internal/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ Class | Method | HTTP request | Description
- [CloudVersionMatchmakerCaptchaHcaptcha](docs/CloudVersionMatchmakerCaptchaHcaptcha.md)
- [CloudVersionMatchmakerCaptchaHcaptchaLevel](docs/CloudVersionMatchmakerCaptchaHcaptchaLevel.md)
- [CloudVersionMatchmakerCaptchaTurnstile](docs/CloudVersionMatchmakerCaptchaTurnstile.md)
- [CloudVersionMatchmakerCaptchaTurnstileDomain](docs/CloudVersionMatchmakerCaptchaTurnstileDomain.md)
- [CloudVersionMatchmakerConfig](docs/CloudVersionMatchmakerConfig.md)
- [CloudVersionMatchmakerGameMode](docs/CloudVersionMatchmakerGameMode.md)
- [CloudVersionMatchmakerGameModeActions](docs/CloudVersionMatchmakerGameModeActions.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**domains** | [**::std::collections::HashMap<String, crate::models::CloudVersionMatchmakerCaptchaTurnstileDomain>**](CloudVersionMatchmakerCaptchaTurnstileDomain.md) | |
**secret_key** | **String** | |
**site_key** | **String** | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct CloudVersionMatchmakerCaptchaTurnstile {
#[serde(rename = "domains")]
pub domains: ::std::collections::HashMap<String, crate::models::CloudVersionMatchmakerCaptchaTurnstileDomain>,
#[serde(rename = "secret_key")]
pub secret_key: String,
#[serde(rename = "site_key")]
pub site_key: String,
}

impl CloudVersionMatchmakerCaptchaTurnstile {
/// Turnstile captcha configuration.
pub fn new(domains: ::std::collections::HashMap<String, crate::models::CloudVersionMatchmakerCaptchaTurnstileDomain>) -> CloudVersionMatchmakerCaptchaTurnstile {
pub fn new(secret_key: String, site_key: String) -> CloudVersionMatchmakerCaptchaTurnstile {
CloudVersionMatchmakerCaptchaTurnstile {
domains,
secret_key,
site_key,
}
}
}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions gen/openapi/internal/rust/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ pub mod cloud_version_matchmaker_captcha_hcaptcha_level;
pub use self::cloud_version_matchmaker_captcha_hcaptcha_level::CloudVersionMatchmakerCaptchaHcaptchaLevel;
pub mod cloud_version_matchmaker_captcha_turnstile;
pub use self::cloud_version_matchmaker_captcha_turnstile::CloudVersionMatchmakerCaptchaTurnstile;
pub mod cloud_version_matchmaker_captcha_turnstile_domain;
pub use self::cloud_version_matchmaker_captcha_turnstile_domain::CloudVersionMatchmakerCaptchaTurnstileDomain;
pub mod cloud_version_matchmaker_config;
pub use self::cloud_version_matchmaker_config::CloudVersionMatchmakerConfig;
pub mod cloud_version_matchmaker_game_mode;
Expand Down
13 changes: 3 additions & 10 deletions gen/openapi/internal/spec/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10742,19 +10742,12 @@ components:
type: object
description: Turnstile captcha configuration.
properties:
domains:
type: object
additionalProperties:
$ref: '#/components/schemas/CloudVersionMatchmakerCaptchaTurnstileDomain'
required:
- domains
CloudVersionMatchmakerCaptchaTurnstileDomain:
type: object
description: Turnstile domain configuration.
properties:
site_key:
type: string
secret_key:
type: string
required:
- site_key
- secret_key
CloudVersionMatchmakerNetworkMode:
type: string
Expand Down
13 changes: 3 additions & 10 deletions gen/openapi/internal/spec_compat/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2002,20 +2002,13 @@ components:
type: string
CloudVersionMatchmakerCaptchaTurnstile:
description: Turnstile captcha configuration.
properties:
domains:
additionalProperties:
$ref: '#/components/schemas/CloudVersionMatchmakerCaptchaTurnstileDomain'
type: object
required:
- domains
type: object
CloudVersionMatchmakerCaptchaTurnstileDomain:
description: Turnstile domain configuration.
properties:
secret_key:
type: string
site_key:
type: string
required:
- site_key
- secret_key
type: object
CloudVersionMatchmakerConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub fn vector(config: &VectorConfig) -> String {

let mut config_str = formatdoc!(
r#"
[api-routes]
[api]
enabled = true

[sinks.vector_sink]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ fn region_to_proto(
.clone()
.or_else(|| game_mode.idle_lobbies.clone())
.or_else(|| matchmaker.idle_lobbies.clone())
// TODO: Remove? idle lobby default is 0
.unwrap_or_else(|| {
Box::new(models::CloudVersionMatchmakerGameModeIdleLobbiesConfig {
min: util_mm::defaults::IDLE_LOBBIES_MIN as i32,
Expand Down
29 changes: 4 additions & 25 deletions lib/convert/src/impls/cloud/version/matchmaker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,8 @@ impl ApiFrom<models::CloudVersionMatchmakerCaptchaTurnstile>
value: models::CloudVersionMatchmakerCaptchaTurnstile,
) -> backend::captcha::captcha_config::Turnstile {
backend::captcha::captcha_config::Turnstile {
domains: value
.domains
.into_iter()
.map(
|(domain, value)| backend::captcha::captcha_config::turnstile::Domain {
domain,
secret_key: value.secret_key,
},
)
.collect::<Vec<_>>(),
site_key: value.site_key,
secret_key: value.secret_key,
}
}
}
Expand All @@ -403,21 +395,8 @@ impl ApiTryFrom<backend::captcha::captcha_config::Turnstile>

fn try_from(value: backend::captcha::captcha_config::Turnstile) -> GlobalResult<Self> {
Ok(models::CloudVersionMatchmakerCaptchaTurnstile {
domains: value
.domains
.into_iter()
.map(|d| (d.domain.clone(), ApiInto::api_into(d)))
.collect::<HashMap<_, _>>(),
})
}
}

impl ApiFrom<backend::captcha::captcha_config::turnstile::Domain>
for models::CloudVersionMatchmakerCaptchaTurnstileDomain
{
fn api_from(value: backend::captcha::captcha_config::turnstile::Domain) -> Self {
models::CloudVersionMatchmakerCaptchaTurnstileDomain {
site_key: value.site_key,
secret_key: value.secret_key,
}
})
}
}
8 changes: 2 additions & 6 deletions proto/backend/captcha.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ message CaptchaConfig {
}

message Turnstile {
message Domain {
string domain = 1;
string secret_key = 2;
}

repeated Domain domains = 1;
string site_key = 1;
string secret_key = 2;
}

// How many times a user can bypass the captcha before being prompted
Expand Down
36 changes: 24 additions & 12 deletions svc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4f459b3

Please sign in to comment.