Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up WebAuthn javascript code and remove JQuery code #22697

Merged
merged 34 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
df2adb2
Fix Uncaught DOMException: Failed to execute 'atob' on 'Window'
zeripath Jan 29, 2023
f40e516
Update web_src/js/features/user-auth-webauthn.js
zeripath Jan 29, 2023
07e40bd
Merge branch 'main' into fix-atob-on-window
zeripath Jan 29, 2023
dcd6307
Include findings from #22654
zeripath Jan 29, 2023
4a910b9
Merge remote-tracking branch 'zeripath/fix-atob-on-window' into fix-a…
zeripath Jan 29, 2023
f038244
As per wxiaoguang
zeripath Jan 30, 2023
6326456
Merge branch 'main' into fix-atob-on-window
zeripath Jan 30, 2023
7864ed8
Merge branch 'main' into fix-atob-on-window
zeripath Jan 31, 2023
b37e6a1
fix test
zeripath Jan 31, 2023
104a864
Clean up WebAuthn javascript code and remove JQuery code
zeripath Jan 31, 2023
7acd2a3
Merge branch 'main' into follow-up-fix-atob-on-window
zeripath Feb 1, 2023
834c30f
as per silverwind
zeripath Feb 2, 2023
dbfdea9
Update user-auth-webauthn.js
zeripath Feb 2, 2023
983c6d3
fix-broken-suggestion
zeripath Feb 2, 2023
0414113
Merge remote-tracking branch 'origin/main' into follow-up-fix-atob-on…
zeripath Feb 2, 2023
4ff437c
Merge remote-tracking branch 'origin/main' into follow-up-fix-atob-on…
zeripath May 4, 2023
b8c6827
move base64 functions, add test
silverwind May 4, 2023
074173c
Merge remote-tracking branch 'origin/main' into follow-up-fix-atob-on…
zeripath May 10, 2023
2961333
as per reviews
zeripath May 10, 2023
e402020
more reviews
zeripath May 10, 2023
c4fd5bb
add more testcases
zeripath May 10, 2023
43c616e
Merge branch 'main' into follow-up-fix-atob-on-window
zeripath May 10, 2023
1abde48
Merge branch 'main' into follow-up-fix-atob-on-window
silverwind May 12, 2023
f500353
Merge branch 'main' into follow-up-fix-atob-on-window
GiteaBot Jun 4, 2023
3026b5b
Merge branch 'main' into follow-up-fix-atob-on-window
GiteaBot Jun 4, 2023
3f918f8
Merge branch 'main' into follow-up-fix-atob-on-window
GiteaBot Jun 5, 2023
d412383
Update web_src/js/features/user-auth-webauthn.js
silverwind Jun 5, 2023
90575a0
Merge branch 'main' into follow-up-fix-atob-on-window
silverwind Jun 5, 2023
63e417e
remove p tags, remove stange box-shadow
silverwind Jun 5, 2023
fd08d9e
add message header colors
silverwind Jun 5, 2023
93ba232
use showElem, hideElem
silverwind Jun 5, 2023
41dba0c
reformat html
silverwind Jun 5, 2023
1ce6d71
Merge branch 'main' into follow-up-fix-atob-on-window
GiteaBot Jun 6, 2023
33de52e
Merge branch 'main' into follow-up-fix-atob-on-window
GiteaBot Jun 6, 2023
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
6 changes: 4 additions & 2 deletions routers/web/user/setting/security/webauthn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package security
import (
"errors"
"net/http"
"strconv"
"time"

"code.gitea.io/gitea/models/auth"
wa "code.gitea.io/gitea/modules/auth/webauthn"
Expand All @@ -23,8 +25,8 @@ import (
func WebAuthnRegister(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.WebauthnRegistrationForm)
if form.Name == "" {
ctx.Error(http.StatusConflict)
return
// Set name to the hexadecimal of the current time
form.Name = strconv.FormatInt(time.Now().UnixNano(), 16)
}

cred, err := auth.GetWebAuthnCredentialByName(ctx.Doer.ID, form.Name)
Expand Down
2 changes: 1 addition & 1 deletion templates/user/auth/webauthn.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<h3 class="ui top attached header">
{{.locale.Tr "twofa"}}
</h3>
{{template "user/auth/webauthn_error" .}}
<div class="ui attached segment">
{{svg "octicon-key" 56}}
<h3>{{.locale.Tr "webauthn_insert_key"}}</h3>
Expand All @@ -18,5 +19,4 @@
</div>
</div>
</div>
{{template "user/auth/webauthn_error" .}}
{{template "base/footer" .}}
30 changes: 12 additions & 18 deletions templates/user/auth/webauthn_error.tmpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<div class="ui small modal" id="webauthn-error">
<div class="header">{{.locale.Tr "webauthn_error"}}</div>
<div class="content">
<div class="ui negative message">
<div class="header">
<div id="webauthn-error" class="ui small gt-hidden">
<div class="content ui negative message">
<div class="header">
{{.locale.Tr "webauthn_error"}}
</div>
<div class="gt-hidden" data-webauthn-error-msg="browser"><p>{{.locale.Tr "webauthn_unsupported_browser"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="unknown"><p>{{.locale.Tr "webauthn_error_unknown"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="insecure"><p>{{.locale.Tr "webauthn_error_insecure"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="unable-to-process"><p>{{.locale.Tr "webauthn_error_unable_to_process"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="duplicated"><p>{{.locale.Tr "webauthn_error_duplicated"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="empty"><p>{{.locale.Tr "webauthn_error_empty"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="timeout"><p>{{.locale.Tr "webauthn_error_timeout"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="general"></div>
</div>
</div>
<div class="actions">
<button onclick="window.location.reload()" class="success ui button gt-hidden webauthn_error_timeout">{{.locale.Tr "webauthn_reload"}}</button>
<button class="ui cancel button">{{.locale.Tr "cancel"}}</button>
<div id="webauthn-error-msg" class="">
</div>
<div class="gt-hidden" data-webauthn-error-msg="browser"><p>{{.locale.Tr "webauthn_unsupported_browser"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="unknown"><p>{{.locale.Tr "webauthn_error_unknown"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="insecure"><p>{{.locale.Tr "webauthn_error_insecure"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="unable-to-process"><p>{{.locale.Tr "webauthn_error_unable_to_process"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="duplicated"><p>{{.locale.Tr "webauthn_error_duplicated"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="empty"><p>{{.locale.Tr "webauthn_error_empty"}}</div>
<div class="gt-hidden" data-webauthn-error-msg="timeout"><p>{{.locale.Tr "webauthn_error_timeout"}}</div>
silverwind marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
2 changes: 1 addition & 1 deletion templates/user/settings/security/webauthn.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
</h4>
<div class="ui attached segment">
<p>{{.locale.Tr "settings.webauthn_desc" | Str2html}}</p>
{{template "user/auth/webauthn_error" .}}
<div class="ui key list">
{{range .WebAuthnCredentials}}
<div class="item">
Expand All @@ -28,7 +29,6 @@
</div>
</div>

{{template "user/auth/webauthn_error" .}}

<div class="ui g-modal-confirm delete modal" id="delete-registration">
<div class="header">
Expand Down
Loading