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

Commit

Permalink
user report messaging and signing (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehelmick authored Apr 2, 2021
1 parent ebafa7b commit a3363dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion assets/server/realmadmin/_form_sms.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<a class="dropdown-item" id="sms-template-new" href="#">New SMS template</a>
</div>
{{if $realm.AllowsUserReport}}
<small class="form-text text-muted">User initiated report is enabled, which always uses the <code>User Report</code> template.</small>
<small class="form-text text-muted">&nbsp;User initiated report is enabled, which always uses the <code>User Report</code> template.</small>
{{end}}
</div>
{{if $realm.ErrorsFor "smsTextTemplate"}}
Expand All @@ -158,6 +158,12 @@
{{joinStrings ($realm.ErrorsFor $v.Label) ", "}}
</div>
{{end}}
{{if (eq "User Report" $v.Label)}}
<div class="alert alert-warning" role="alert">
For the <strong>User Report</strong> template it is strongly recommended that you
indicate that the user should not use the code if they did not request it.
</div>
{{end}}
{{if or (not $realm.AllowsUserReport) (ne "User Report" $v.Label)}}
<button class="btn btn-danger mb-3 {{if eq $i 0}}d-none{{end}}" type="button" {{if ne $i 0}}onClick="removeTemplate('sms-template-{{$i}}');"{{end}}>Delete template</button>
{{end}}
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/issueapi/send_sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func (c *Controller) doSend(ctx context.Context, realm *database.Realm, smsProvi
// SMS signing.
if signer != nil {
var err error
message, err = signatures.SignSMS(signer, keyID, smsStart, signatures.SMSPurposeENReport, request.Phone, message)
purpose := signatures.SMSPurposeENReport
if request.TestType == api.TestTypeUserReport {
purpose = signatures.SMSPurposeUserReport
}
message, err = signatures.SignSMS(signer, keyID, smsStart, purpose, request.Phone, message)
if err != nil {
defer func() {
if err := stats.RecordWithOptions(ctx,
Expand Down
3 changes: 2 additions & 1 deletion pkg/signatures/sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type SMSPurpose string

const (
// SMSPurposeENReport is an SMS purpose for EN reporting.
SMSPurposeENReport SMSPurpose = "EN Report"
SMSPurposeENReport SMSPurpose = "EN Report"
SMSPurposeUserReport SMSPurpose = "User Report"
)

// SignSMS returns a new SMS message with the embedded signature using the
Expand Down

0 comments on commit a3363dc

Please sign in to comment.