Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4373f35

Browse files
committed
feat: allow masking workspace parameter inputs
1 parentfdf458e commit4373f35

File tree

12 files changed

+335
-33
lines changed

12 files changed

+335
-33
lines changed

‎coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/db2sdk/db2sdk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ func PreviewParameter(param previewtypes.Parameter) codersdk.PreviewParameter {
816816
Placeholder:param.Styling.Placeholder,
817817
Disabled:param.Styling.Disabled,
818818
Label:param.Styling.Label,
819+
MaskInput:param.Styling.MaskInput,
819820
},
820821
Mutable:param.Mutable,
821822
DefaultValue:PreviewHCLString(param.DefaultValue),

‎codersdk/parameters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type PreviewParameterStyling struct {
9191
Placeholder*string`json:"placeholder,omitempty"`
9292
Disabled*bool`json:"disabled,omitempty"`
9393
Label*string`json:"label,omitempty"`
94+
MaskInput*bool`json:"mask_input,omitempty"`
9495
}
9596

9697
typePreviewParameterOptionstruct {
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#Mask Input Feature
2+
3+
The`mask_input` styling option allows you to hide sensitive parameter values by converting all characters to asterisks (*). This feature is designed for template parameters that contain sensitive information like passwords, API keys, or other secrets.
4+
5+
>**Note**: This feature is purely cosmetic and does not provide any security. The actual parameter values are still transmitted and stored normally. This is only meant to hide the characters visually in the UI.
6+
7+
##Usage
8+
9+
The`mask_input` option can be applied to parameters with`form_type` of`input` or`textarea`. Add it to the`styling` block of your parameter definition:
10+
11+
```hcl
12+
variable "api_key" {
13+
description = "API key for external service"
14+
type = string
15+
sensitive = true
16+
17+
validation {
18+
condition = length(var.api_key) > 0
19+
error_message = "API key cannot be empty."
20+
}
21+
}
22+
23+
resource "coder_parameter" "api_key" {
24+
name = "api_key"
25+
display_name = "API Key"
26+
description = "Enter your API key for the external service"
27+
type = "string"
28+
form_type = "input"
29+
mutable = true
30+
31+
styling = {
32+
mask_input = true
33+
placeholder = "Enter your API key"
34+
}
35+
}
36+
```
37+
38+
##Examples
39+
40+
###Masked Input Field
41+
42+
```hcl
43+
resource "coder_parameter" "database_password" {
44+
name = "database_password"
45+
display_name = "Database Password"
46+
description = "Password for database connection"
47+
type = "string"
48+
form_type = "input"
49+
mutable = true
50+
51+
styling = {
52+
mask_input = true
53+
}
54+
}
55+
```
56+
57+
###Masked Textarea Field
58+
59+
```hcl
60+
resource "coder_parameter" "private_key" {
61+
name = "private_key"
62+
display_name = "Private Key"
63+
description = "Private key for SSH access"
64+
type = "string"
65+
form_type = "textarea"
66+
mutable = true
67+
68+
styling = {
69+
mask_input = true
70+
placeholder = "Paste your private key here"
71+
}
72+
}
73+
```
74+
75+
###Complete Example with Multiple Sensitive Parameters
76+
77+
```hcl
78+
terraform {
79+
required_providers {
80+
coder = {
81+
source = "coder/coder"
82+
}
83+
}
84+
}
85+
86+
variable "username" {
87+
description = "Username for the service"
88+
type = string
89+
}
90+
91+
variable "password" {
92+
description = "Password for the service"
93+
type = string
94+
sensitive = true
95+
}
96+
97+
variable "ssl_certificate" {
98+
description = "SSL certificate content"
99+
type = string
100+
sensitive = true
101+
}
102+
103+
resource "coder_parameter" "username" {
104+
name = "username"
105+
display_name = "Username"
106+
description = "Enter your username"
107+
type = "string"
108+
form_type = "input"
109+
mutable = true
110+
default_value = var.username
111+
}
112+
113+
resource "coder_parameter" "password" {
114+
name = "password"
115+
display_name = "Password"
116+
description = "Enter your password"
117+
type = "string"
118+
form_type = "input"
119+
mutable = true
120+
default_value = var.password
121+
122+
styling = {
123+
mask_input = true
124+
placeholder = "Enter your password"
125+
}
126+
}
127+
128+
resource "coder_parameter" "ssl_certificate" {
129+
name = "ssl_certificate"
130+
display_name = "SSL Certificate"
131+
description = "Paste your SSL certificate"
132+
type = "string"
133+
form_type = "textarea"
134+
mutable = true
135+
default_value = var.ssl_certificate
136+
137+
styling = {
138+
mask_input = true
139+
placeholder = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
140+
}
141+
}
142+
```
143+
144+
##User Interface Behavior
145+
146+
When`mask_input` is enabled:
147+
148+
1.**Masked Display**: All characters in the input field are displayed as asterisks (*)
149+
2.**Show/Hide Toggle**: A eye icon button appears in the top-right corner of the field
150+
- Click the eye icon to reveal the actual text
151+
- Click again to hide it back to asterisks
152+
3.**Normal Functionality**: The field works normally for typing, copying, and pasting
153+
4.**Form Submission**: The actual unmasked value is submitted with the form
154+
155+
##Limitations and Considerations
156+
157+
-**No Security**: This feature provides no actual security - it's purely visual
158+
-**Number Fields**: Masking is automatically disabled for`number` type parameters
159+
-**Accessibility**: Screen readers will still read the actual values, not the masked version
160+
-**Development**: Use in conjunction with Terraform's`sensitive = true` for variables that contain secrets
161+
162+
##Best Practices
163+
164+
1.**Combine with Sensitive Variables**: Always mark sensitive parameters with`sensitive = true` in your Terraform variables
165+
2.**Use Descriptive Placeholders**: Provide helpful placeholder text to guide users
166+
3.**Validate Input**: Add appropriate validation rules for sensitive parameters
167+
4.**Documentation**: Clearly document what sensitive information is being collected
168+
169+
```hcl
170+
variable "api_token" {
171+
description = "API token for external service (keep this secret!)"
172+
type = string
173+
sensitive = true # This prevents the value from appearing in Terraform logs
174+
175+
validation {
176+
condition = can(regex("^[A-Za-z0-9]{32,}$", var.api_token))
177+
error_message = "API token must be at least 32 alphanumeric characters."
178+
}
179+
}
180+
181+
resource "coder_parameter" "api_token" {
182+
name = "api_token"
183+
display_name = "API Token"
184+
description = "Enter your API token (this will be hidden for security)"
185+
type = "string"
186+
form_type = "input"
187+
mutable = true
188+
default_value = var.api_token
189+
190+
styling = {
191+
mask_input = true
192+
placeholder = "Enter your 32+ character API token"
193+
}
194+
}
195+
```

‎docs/reference/api/schemas.md

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/reference/api/templates.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ replace github.com/spf13/afero => github.com/aslilac/afero v0.0.0-20250403163713
7575
// TODO: replace once we cut release.
7676
replacegithub.com/coder/terraform-provider-coder/v2 =>github.com/coder/terraform-provider-coder/v2v2.7.1-0.20250623193313-e890833351e2
7777

78+
replacegithub.com/coder/preview =>github.com/coder/previewv1.0.2-0.20250625231609-10623f47565b
79+
7880
require (
7981
cdr.dev/slogv1.6.2-0.20241112041820-0ec81e6e67bb
8082
cloud.google.com/go/compute/metadatav0.7.0

‎go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ github.com/coder/pq v1.10.5-0.20240813183442-0c420cb5a048 h1:3jzYUlGH7ZELIH4XggX
916916
github.com/coder/pqv1.10.5-0.20240813183442-0c420cb5a048/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
917917
github.com/coder/prettyv0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=
918918
github.com/coder/prettyv0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
919-
github.com/coder/previewv1.0.1 h1:f6q+RjNelwnkyXfGbmVlb4dcUOQ0z4mPsb2kuQpFHuU=
920-
github.com/coder/previewv1.0.1/go.mod h1:efDWGlO/PZPrvdt5QiDhMtTUTkPxejXo9c0wmYYLLjM=
919+
github.com/coder/previewv1.0.2-0.20250625231609-10623f47565b h1:nka6oEgL/+GR78IcdwgG6CNDEpgLD1JFGts8h7yLD5w=
920+
github.com/coder/previewv1.0.2-0.20250625231609-10623f47565b/go.mod h1:efDWGlO/PZPrvdt5QiDhMtTUTkPxejXo9c0wmYYLLjM=
921921
github.com/coder/quartzv0.2.1 h1:QgQ2Vc1+mvzewg2uD/nj8MJ9p9gE+QhGJm+Z+NGnrSE=
922922
github.com/coder/quartzv0.2.1/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
923923
github.com/coder/retryv1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=

‎site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/modules/workspaces/DynamicParameter/DynamicParameter.stories.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,42 @@ export const AllBadges: Story = {
230230
isPreset:true,
231231
},
232232
};
233+
234+
exportconstMaskedInput:Story={
235+
args:{
236+
parameter:{
237+
...MockPreviewParameter,
238+
form_type:"input",
239+
styling:{
240+
...MockPreviewParameter.styling,
241+
mask_input:true,
242+
},
243+
},
244+
},
245+
};
246+
247+
exportconstMaskedTextArea:Story={
248+
args:{
249+
parameter:{
250+
...MockPreviewParameter,
251+
form_type:"textarea",
252+
styling:{
253+
...MockPreviewParameter.styling,
254+
mask_input:true,
255+
},
256+
},
257+
},
258+
};
259+
260+
exportconstMaskedInputWithPlaceholder:Story={
261+
args:{
262+
parameter:{
263+
...MockPreviewParameter,
264+
form_type:"input",
265+
styling:{
266+
placeholder:"Enter your secret value",
267+
mask_input:true,
268+
},
269+
},
270+
},
271+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp