diff options
author | Jonas Franz <info@jonasfranz.software> | 2019-03-08 17:42:50 +0100 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-03-08 11:42:50 -0500 |
commit | e777c6bdc6f12f9152335f8bfd66b956aedc9957 (patch) | |
tree | b79c9bc2d4f9402dcd15d993b088840e2fad8a54 /templates/user | |
parent | 9d3732dfd512273992855097bba1e909f098db23 (diff) | |
download | gitea-e777c6bdc6f12f9152335f8bfd66b956aedc9957.tar.gz gitea-e777c6bdc6f12f9152335f8bfd66b956aedc9957.zip |
Integrate OAuth2 Provider (#5378)
Diffstat (limited to 'templates/user')
-rw-r--r-- | templates/user/auth/grant.tmpl | 31 | ||||
-rw-r--r-- | templates/user/auth/grant_error.tmpl | 16 | ||||
-rw-r--r-- | templates/user/settings/applications.tmpl | 4 | ||||
-rw-r--r-- | templates/user/settings/applications_oauth2.tmpl | 58 | ||||
-rw-r--r-- | templates/user/settings/applications_oauth2_edit.tmpl | 66 |
5 files changed, 175 insertions, 0 deletions
diff --git a/templates/user/auth/grant.tmpl b/templates/user/auth/grant.tmpl new file mode 100644 index 0000000000..85c507a74a --- /dev/null +++ b/templates/user/auth/grant.tmpl @@ -0,0 +1,31 @@ +{{template "base/head" .}} +<div class="ui one column stackable center aligned page grid oauth2-authorize-application-box"> + <div class="column seven wide"> + <div class="ui middle centered raised segments"> + <h3 class="ui top attached header"> + {{.i18n.Tr "auth.authorize_title" .Application.Name}} + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <p> + <b>{{.i18n.Tr "auth.authorize_application_description"}}</b><br/> + {{.i18n.Tr "auth.authorize_application_created_by" .ApplicationUserLink | Str2html}} + </p> + </div> + <div class="ui attached segment"> + <p>{{.i18n.Tr "auth.authroize_redirect_notice" .ApplicationRedirectDomainHTML | Str2html}}</p> + </div> + <div class="ui attached segment"> + <form method="post" action="{{.AppSubUrl}}/login/oauth/grant"> + {{.CsrfTokenHtml}} + <input type="hidden" name="client_id" value="{{.Application.ClientID}}"> + <input type="hidden" name="state" value="{{.State}}"> + <input type="hidden" name="redirect_uri" value="{{.RedirectURI}}"> + <input type="submit" id="authorize-app" value="{{.i18n.Tr "auth.authorize_application"}}" class="ui red inline button"/> + <a href="{{.RedirectURI}}" class="ui basic primary inline button">Cancel</a> + </form> + </div> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/user/auth/grant_error.tmpl b/templates/user/auth/grant_error.tmpl new file mode 100644 index 0000000000..0eb175fbe2 --- /dev/null +++ b/templates/user/auth/grant_error.tmpl @@ -0,0 +1,16 @@ +{{template "base/head" .}} +{{if .IsRepo}}<div class="repository">{{template "repo/header" .}}</div>{{end}} +<div class="ui one column stackable center aligned page grid oauth2-authorize-application-box"> + <div class="column seven wide"> + <div class="ui middle centered raised segments"> + <h1 class="ui top attached header"> + {{.i18n.Tr "auth.authorization_failed" }} + </h1> + <h3 class="ui attached segment">{{.Error.ErrorDescription}}</h3> + <div class="ui attached segment"> + <p>{{.i18n.Tr "auth.authorization_failed_desc"}}</p> + </div> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/user/settings/applications.tmpl b/templates/user/settings/applications.tmpl index d842644185..1a3ab5efaf 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -45,6 +45,10 @@ </button> </form> </div> + + {{if .EnableOAuth2}} + {{template "user/settings/applications_oauth2" .}} + {{end}} </div> </div> diff --git a/templates/user/settings/applications_oauth2.tmpl b/templates/user/settings/applications_oauth2.tmpl new file mode 100644 index 0000000000..42d1950f9f --- /dev/null +++ b/templates/user/settings/applications_oauth2.tmpl @@ -0,0 +1,58 @@ +<h4 class="ui top attached header"> + {{.i18n.Tr "settings.manage_oauth2_applications"}} +</h4> +<div class="ui attached segment"> + <div class="ui key list"> + <div class="item"> + {{.i18n.Tr "settings.oauth2_application_create_description"}} + </div> + {{range $app := .Applications}} + <div class="item"> + <div class="right floated content"> + <a href="{{$.Link}}/oauth2/{{$app.ID}}" class="ui primary tiny icon button"> + <i class="pencil alternate icon"></i> + {{$.i18n.Tr "settings.oauth2_application_edit"}} + </a> + <button class="ui red tiny button delete-button" id="remove-gitea-oauth2-application" + data-url="{{AppSubUrl}}/user/settings/applications/oauth2/delete" + data-id="{{$app.ID}}"> + {{$.i18n.Tr "settings.delete_key"}} + </button> + </div> + <div class="content"> + <strong>{{$app.Name}}</strong> + </div> + </div> + {{end}} + </div> +</div> +<div class="ui attached bottom segment"> + <h5 class="ui top header"> + {{.i18n.Tr "settings.create_oauth2_application" }} + </h5> + <form class="ui form ignore-dirty" action="{{.Link}}/oauth2" method="post"> + {{.CsrfTokenHtml}} + <div class="field {{if .Err_AppName}}error{{end}}"> + <label for="application-name">{{.i18n.Tr "settings.oauth2_application_name"}}</label> + <input id="application-name" name="application_name" value="{{.application_name}}" required> + </div> + <div class="field {{if .Err_RedirectURI}}error{{end}}"> + <label for="redirect-uri">{{.i18n.Tr "settings.oauth2_redirect_uri"}}</label> + <input type="url" name="redirect_uri" id="redirect-uri"> + </div> + <button class="ui green button"> + {{.i18n.Tr "settings.create_oauth2_application_button"}} + </button> + </form> +</div> + +<div class="ui small basic delete modal" id="remove-gitea-oauth2-application"> + <div class="ui icon header"> + <i class="trash icon"></i> + {{.i18n.Tr "settings.remove_oauth2_application"}} + </div> + <div class="content"> + <p>{{.i18n.Tr "settings.oauth2_application_remove_description"}}</p> + </div> + {{template "base/delete_modal_actions" .}} +</div> diff --git a/templates/user/settings/applications_oauth2_edit.tmpl b/templates/user/settings/applications_oauth2_edit.tmpl new file mode 100644 index 0000000000..5de179ecaf --- /dev/null +++ b/templates/user/settings/applications_oauth2_edit.tmpl @@ -0,0 +1,66 @@ +{{template "base/head" .}} +<div class="user settings applications"> + {{template "user/settings/navbar" .}} + <div class="ui container"> + {{template "base/alert" .}} + <h4 class="ui top attached header"> + {{.i18n.Tr "settings.edit_oauth2_application"}} + </h4> + <div class="ui attached segment"> + {{template "base/alert" .}} + <p>{{.i18n.Tr "settings.oauth2_application_create_description"}}</p> + </div> + <div class="ui attached segment form ignore-dirty"> + {{.CsrfTokenHtml}} + <div class="field"> + <label for="client-id">{{.i18n.Tr "settings.oauth2_client_id"}}</label> + <input id="client-id" readonly value="{{.App.ClientID}}"> + </div> + {{if .ClientSecret}} + <div class="field"> + <label for="client-secret">{{.i18n.Tr "settings.oauth2_client_secret"}}</label> + <input id="client-secret" type="text" readonly value="{{.ClientSecret}}"> + </div> + {{else}} + <div class="field"> + <label for="client-secret">{{.i18n.Tr "settings.oauth2_client_secret"}}</label> + <input id="client-secret" type="password" readonly value="averysecuresecret"> + </div> + {{end}} + <div class="item"> + <!-- TODO add regenerate secret functionality */ --> + {{.i18n.Tr "settings.oauth2_regenerate_secret_hint"}} + <a onclick="alert('Not yet implemented.')">{{.i18n.Tr "settings.oauth2_regenerate_secret"}}</a> + </div> + </div> + <div class="ui attached bottom segment"> + <form class="ui form ignore-dirty" action="{{$.AppSubURL}}/user/settings/applications/oauth2/{{.App.ID}}" method="post"> + {{.CsrfTokenHtml}} + <div class="field {{if .Err_AppName}}error{{end}}"> + <label for="application-name">{{.i18n.Tr "settings.oauth2_application_name"}}</label> + <input id="application-name" value="{{.App.Name}}" name="application_name" required> + </div> + <div class="field {{if .Err_RedirectURI}}error{{end}}"> + <label for="redirect-uri">{{.i18n.Tr "settings.oauth2_redirect_uri"}}</label> + <input type="url" name="redirect_uri" value="{{.App.PrimaryRedirectURI}}" id="redirect-uri"> + </div> + <button class="ui green button"> + {{.i18n.Tr "settings.save_application"}} + </button> + </form> + </div> + </div> +</div> + +<div class="ui small basic delete modal" id="delete-oauth2-application"> + <div class="ui icon header"> + <i class="trash icon"></i> + {{.i18n.Tr "settings.remove_oauth2_application"}} + </div> + <div class="content"> + <p>{{.i18n.Tr "settings.remove_oauth2_application_desc"}}</p> + </div> + {{template "base/delete_modal_actions" .}} +</div> + +{{template "base/footer" .}} |