mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-14 06:50:25 +00:00
Replace the anti-CSRF token with a [cross origin protection by Go](https://go.dev/doc/go1.25#nethttppkgnethttp) that uses a stateless way of verifying if a request was cross origin or not. This allows is to remove al lot of code and replace it with a few lines of code and we no longer have to hand roll this protection. The new protection uses indicators by the browser itself that indicate if the request is cross-origin, thus we no longer have to take care of ensuring the generated CSRF token is passed back to the server any request by the the browser will have send this indicator. Resolves forgejo/forgejo#3538 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9830 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
118 lines
5.3 KiB
Go HTML Template
118 lines
5.3 KiB
Go HTML Template
{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin new authentication")}}
|
|
<div class="admin-setting-content">
|
|
<h4 class="ui top attached header">
|
|
{{ctx.Locale.Tr "admin.auths.new"}}
|
|
</h4>
|
|
<div class="ui attached segment">
|
|
<form class="ui form" action="{{.Link}}" method="post">
|
|
{{template "base/disable_form_autofill"}}
|
|
<!-- Types and name -->
|
|
<div class="inline required field {{if .Err_Type}}error{{end}}">
|
|
<label>{{ctx.Locale.Tr "admin.auths.auth_type"}}</label>
|
|
<div class="ui selection type dropdown">
|
|
<input type="hidden" id="auth_type" name="type" value="{{.type}}">
|
|
<div class="text">{{.CurrentTypeName}}</div>
|
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
|
<div class="menu">
|
|
{{range .AuthSources}}
|
|
<div class="item" data-value="{{.Type.Int}}">{{.Name}}</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="required inline field {{if .Err_Name}}error{{end}}">
|
|
<label for="auth_name">{{ctx.Locale.Tr "admin.auths.auth_name"}}</label>
|
|
<input id="auth_name" name="name" value="{{.name}}" autofocus required>
|
|
</div>
|
|
|
|
<!-- LDAP and DLDAP -->
|
|
{{template "admin/auth/source/ldap" .}}
|
|
|
|
<!-- SMTP -->
|
|
{{template "admin/auth/source/smtp" .}}
|
|
|
|
<!-- PAM -->
|
|
<div class="pam required field {{if not (eq .type 4)}}tw-hidden{{end}}">
|
|
<label for="pam_service_name">{{ctx.Locale.Tr "admin.auths.pam_service_name"}}</label>
|
|
<input id="pam_service_name" name="pam_service_name" value="{{.pam_service_name}}">
|
|
<label for="pam_email_domain">{{ctx.Locale.Tr "admin.auths.pam_email_domain"}}</label>
|
|
<input id="pam_email_domain" name="pam_email_domain" value="{{.pam_email_domain}}">
|
|
</div>
|
|
<div class="pam optional field {{if not (eq .type 4)}}tw-hidden{{end}}">
|
|
<div class="ui checkbox">
|
|
<label for="skip_local_two_fa"><strong>{{ctx.Locale.Tr "admin.auths.skip_local_two_fa"}}</strong></label>
|
|
<input id="skip_local_two_fa" name="skip_local_two_fa" type="checkbox" {{if .skip_local_two_fa}}checked{{end}}>
|
|
<p class="help">{{ctx.Locale.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- OAuth2 -->
|
|
{{template "admin/auth/source/oauth" .}}
|
|
|
|
<div class="ldap field">
|
|
<div class="ui checkbox">
|
|
<label><strong>{{ctx.Locale.Tr "admin.auths.attributes_in_bind"}}</strong></label>
|
|
<input name="attributes_in_bind" type="checkbox" {{if .attributes_in_bind}}checked{{end}}>
|
|
</div>
|
|
</div>
|
|
<div class="ldap inline field {{if not (eq .type 2)}}tw-hidden{{end}}">
|
|
<div class="ui checkbox">
|
|
<label><strong>{{ctx.Locale.Tr "admin.auths.syncenabled"}}</strong></label>
|
|
<input name="is_sync_enabled" type="checkbox" {{if .is_sync_enabled}}checked{{end}}>
|
|
</div>
|
|
</div>
|
|
<div class="inline field">
|
|
<div class="ui checkbox">
|
|
<label><strong>{{ctx.Locale.Tr "admin.auths.activated"}}</strong></label>
|
|
<input name="is_active" type="checkbox" {{if .is_active}}checked{{end}}>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<button class="ui primary button">{{ctx.Locale.Tr "admin.auths.new"}}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<h4 class="ui top attached header">
|
|
{{ctx.Locale.Tr "admin.auths.tips"}}
|
|
</h4>
|
|
<div class="ui attached segment">
|
|
<h5>{{ctx.Locale.Tr "admin.auths.tips.gmail_settings"}}</h5>
|
|
<p>Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true</p>
|
|
|
|
<h5 class="oauth2">{{ctx.Locale.Tr "admin.auths.tips.oauth2.general"}}:</h5>
|
|
<p class="oauth2">{{ctx.Locale.Tr "admin.auths.tips.oauth2.general.tip"}} <b id="oauth2-callback-url"></b></p>
|
|
|
|
<h5 class="ui top attached header">{{ctx.Locale.Tr "admin.auths.tip.oauth2_provider"}}</h5>
|
|
<div class="ui attached segment">
|
|
<li>Bitbucket</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.bitbucket" "https://bitbucket.org/account/user/{your-username}/oauth-consumers/new"}}</span>
|
|
<li>Dropbox</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.dropbox" "https://www.dropbox.com/developers/apps"}}</span>
|
|
<li>Facebook</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.facebook" "https://developers.facebook.com/apps"}}</span>
|
|
<li>GitHub</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.github" "https://github.com/settings/applications/new"}}</span>
|
|
<li>GitLab</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.gitlab_new" "https://gitlab.com/-/profile/applications"}}</span>
|
|
<li>Google</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.google_plus" "https://console.developers.google.com/"}}</span>
|
|
<li>OpenID Connect</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.openid_connect"}}</span>
|
|
<li>Twitter</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.twitter" "https://dev.twitter.com/apps"}}</span>
|
|
<li>Discord</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.discord" "https://discordapp.com/developers/applications/me"}}</span>
|
|
<li>Gitea</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.gitea" "https://forgejo.org/docs/latest/user/oauth2-provider"}}</span>
|
|
<li>Nextcloud</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.nextcloud"}}</span>
|
|
<li>Yandex</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.yandex" "https://oauth.yandex.com/client/new"}}</span>
|
|
<li>Mastodon</li>
|
|
<span>{{ctx.Locale.Tr "admin.auths.tip.mastodon"}}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{template "admin/layout_footer" .}}
|