You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

new.tmpl 9.4 kB

Oauth2 consumer (#679) * initial stuff for oauth2 login, fails on: * login button on the signIn page to start the OAuth2 flow and a callback for each provider Only GitHub is implemented for now * show login button only when the OAuth2 consumer is configured (and activated) * create macaron group for oauth2 urls * prevent net/http in modules (other then oauth2) * use a new data sessions oauth2 folder for storing the oauth2 session data * add missing 2FA when this is enabled on the user * add password option for OAuth2 user , for use with git over http and login to the GUI * add tip for registering a GitHub OAuth application * at startup of Gitea register all configured providers and also on adding/deleting of new providers * custom handling of errors in oauth2 request init + show better tip * add ExternalLoginUser model and migration script to add it to database * link a external account to an existing account (still need to handle wrong login and signup) and remove if user is removed * remove the linked external account from the user his settings * if user is unknown we allow him to register a new account or link it to some existing account * sign up with button on signin page (als change OAuth2Provider structure so we can store basic stuff about providers) * from gorilla/sessions docs: "Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler as or else you will leak memory!" (we're using gorilla/sessions for storing oauth2 sessions) * use updated goth lib that now supports getting the OAuth2 user if the AccessToken is still valid instead of re-authenticating (prevent flooding the OAuth2 provider)
9 years ago
Oauth2 consumer (#679) * initial stuff for oauth2 login, fails on: * login button on the signIn page to start the OAuth2 flow and a callback for each provider Only GitHub is implemented for now * show login button only when the OAuth2 consumer is configured (and activated) * create macaron group for oauth2 urls * prevent net/http in modules (other then oauth2) * use a new data sessions oauth2 folder for storing the oauth2 session data * add missing 2FA when this is enabled on the user * add password option for OAuth2 user , for use with git over http and login to the GUI * add tip for registering a GitHub OAuth application * at startup of Gitea register all configured providers and also on adding/deleting of new providers * custom handling of errors in oauth2 request init + show better tip * add ExternalLoginUser model and migration script to add it to database * link a external account to an existing account (still need to handle wrong login and signup) and remove if user is removed * remove the linked external account from the user his settings * if user is unknown we allow him to register a new account or link it to some existing account * sign up with button on signin page (als change OAuth2Provider structure so we can store basic stuff about providers) * from gorilla/sessions docs: "Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler as or else you will leak memory!" (we're using gorilla/sessions for storing oauth2 sessions) * use updated goth lib that now supports getting the OAuth2 user if the AccessToken is still valid instead of re-authenticating (prevent flooding the OAuth2 provider)
9 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. {{template "base/head" .}}
  2. <div class="admin new authentication">
  3. <div class="ui container">
  4. <div class="ui grid">
  5. {{template "admin/navbar" .}}
  6. <div class="twelve wide column content">
  7. {{template "base/alert" .}}
  8. <h4 class="ui top attached header">
  9. {{.i18n.Tr "admin.auths.new"}}
  10. </h4>
  11. <div class="ui attached segment">
  12. <form class="ui form" action="{{.Link}}" method="post">
  13. {{.CsrfTokenHtml}}
  14. <!-- Types and name -->
  15. <div class="inline required field {{if .Err_Type}}error{{end}}">
  16. <label>{{.i18n.Tr "admin.auths.auth_type"}}</label>
  17. <div class="ui selection type dropdown">
  18. <input type="hidden" id="auth_type" name="type" value="{{.type}}">
  19. <div class="text">{{.CurrentTypeName}}</div>
  20. <i class="dropdown icon"></i>
  21. <div class="menu">
  22. {{range .AuthSources}}
  23. <div class="item" data-value="{{.Type}}">{{.Name}}</div>
  24. {{end}}
  25. </div>
  26. </div>
  27. </div>
  28. <div class="required inline field {{if .Err_Name}}error{{end}}">
  29. <label for="name">{{.i18n.Tr "admin.auths.auth_name"}}</label>
  30. <input id="name" name="name" value="{{.name}}" autofocus required>
  31. </div>
  32. <!-- LDAP and DLDAP -->
  33. <div class="ldap dldap field {{if not (or (eq .type 2) (eq .type 5))}}hide{{end}}">
  34. <div class="inline required field {{if .Err_SecurityProtocol}}error{{end}}">
  35. <label>{{.i18n.Tr "admin.auths.security_protocol"}}</label>
  36. <div class="ui selection security-protocol dropdown">
  37. <input type="hidden" id="security_protocol" name="security_protocol" value="{{.security_protocol}}">
  38. <div class="text">{{.CurrentSecurityProtocol}}</div>
  39. <i class="dropdown icon"></i>
  40. <div class="menu">
  41. {{range .SecurityProtocols}}
  42. <div class="item" data-value="{{.Type}}">{{.Name}}</div>
  43. {{end}}
  44. </div>
  45. </div>
  46. </div>
  47. <div class="required field">
  48. <label for="host">{{.i18n.Tr "admin.auths.host"}}</label>
  49. <input id="host" name="host" value="{{.host}}" placeholder="e.g. mydomain.com">
  50. </div>
  51. <div class="required field">
  52. <label for="port">{{.i18n.Tr "admin.auths.port"}}</label>
  53. <input id="port" name="port" value="{{.port}}" placeholder="e.g. 636">
  54. </div>
  55. <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
  56. <label for="bind_dn">{{.i18n.Tr "admin.auths.bind_dn"}}</label>
  57. <input id="bind_dn" name="bind_dn" value="{{.bind_dn}}" placeholder="e.g. cn=Search,dc=mydomain,dc=com">
  58. </div>
  59. <input class="fake" type="password">
  60. <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
  61. <label for="bind_password">{{.i18n.Tr "admin.auths.bind_password"}}</label>
  62. <input id="bind_password" name="bind_password" type="password" value="{{.bind_password}}">
  63. <p class="help text red">{{.i18n.Tr "admin.auths.bind_password_helper"}}</p>
  64. </div>
  65. <div class="ldap required field {{if not (eq .type 2)}}hide{{end}}">
  66. <label for="user_base">{{.i18n.Tr "admin.auths.user_base"}}</label>
  67. <input id="user_base" name="user_base" value="{{.user_base}}" placeholder="e.g. ou=Users,dc=mydomain,dc=com">
  68. </div>
  69. <div class="dldap required field {{if not (eq .type 5)}}hide{{end}}">
  70. <label for="user_dn">{{.i18n.Tr "admin.auths.user_dn"}}</label>
  71. <input id="user_dn" name="user_dn" value="{{.user_dn}}" placeholder="e.g. uid=%s,ou=Users,dc=mydomain,dc=com">
  72. </div>
  73. <div class="required field">
  74. <label for="filter">{{.i18n.Tr "admin.auths.filter"}}</label>
  75. <input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))">
  76. </div>
  77. <div class="field">
  78. <label for="admin_filter">{{.i18n.Tr "admin.auths.admin_filter"}}</label>
  79. <input id="admin_filter" name="admin_filter" value="{{.admin_filter}}">
  80. </div>
  81. <div class="field">
  82. <label for="attribute_username">{{.i18n.Tr "admin.auths.attribute_username"}}</label>
  83. <input id="attribute_username" name="attribute_username" value="{{.attribute_username}}" placeholder="{{.i18n.Tr "admin.auths.attribute_username_placeholder"}}">
  84. </div>
  85. <div class="field">
  86. <label for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
  87. <input id="attribute_name" name="attribute_name" value="{{.attribute_name}}">
  88. </div>
  89. <div class="field">
  90. <label for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label>
  91. <input id="attribute_surname" name="attribute_surname" value="{{.attribute_surname}}">
  92. </div>
  93. <div class="required field">
  94. <label for="attribute_mail">{{.i18n.Tr "admin.auths.attribute_mail"}}</label>
  95. <input id="attribute_mail" name="attribute_mail" value="{{.attribute_mail}}" placeholder="e.g. mail">
  96. </div>
  97. </div>
  98. <!-- SMTP -->
  99. <div class="smtp field {{if not (eq .type 3)}}hide{{end}}">
  100. <div class="inline required field">
  101. <label>{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
  102. <div class="ui selection type dropdown">
  103. <input type="hidden" id="smtp_auth" name="smtp_auth" value="{{.smtp_auth}}">
  104. <div class="text">{{.smtp_auth}}</div>
  105. <i class="dropdown icon"></i>
  106. <div class="menu">
  107. {{range .SMTPAuths}}
  108. <div class="item" data-value="{{.}}">{{.}}</div>
  109. {{end}}
  110. </div>
  111. </div>
  112. </div>
  113. <div class="required field">
  114. <label for="smtp_host">{{.i18n.Tr "admin.auths.smtphost"}}</label>
  115. <input id="smtp_host" name="smtp_host" value="{{.smtp_host}}">
  116. </div>
  117. <div class="required field">
  118. <label for="smtp_port">{{.i18n.Tr "admin.auths.smtpport"}}</label>
  119. <input id="smtp_port" name="smtp_port" value="{{.smtp_port}}">
  120. </div>
  121. <div class="field">
  122. <label for="allowed_domains">{{.i18n.Tr "admin.auths.allowed_domains"}}</label>
  123. <input id="allowed_domains" name="allowed_domains" value="{{.allowed_domains}}">
  124. <p class="help">{{.i18n.Tr "admin.auths.allowed_domains_helper"}}</p>
  125. </div>
  126. </div>
  127. <!-- PAM -->
  128. <div class="pam required field {{if not (eq .type 4)}}hide{{end}}">
  129. <label for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
  130. <input id="pam_service_name" name="pam_service_name" value="{{.pam_service_name}}" />
  131. </div>
  132. <!-- OAuth2 -->
  133. <div class="oauth2 field {{if not (eq .type 6)}}hide{{end}}">
  134. <div class="inline required field">
  135. <label>{{.i18n.Tr "admin.auths.oauth2_provider"}}</label>
  136. <div class="ui selection type dropdown">
  137. <input type="hidden" id="oauth2_provider" name="oauth2_provider" value="{{.oauth2_provider}}">
  138. <div class="text">{{.oauth2_provider}}</div>
  139. <i class="dropdown icon"></i>
  140. <div class="menu">
  141. {{range $key, $value := .OAuth2Providers}}
  142. <div class="item" data-value="{{$key}}">{{$value.DisplayName}}</div>
  143. {{end}}
  144. </div>
  145. </div>
  146. </div>
  147. <div class="required field">
  148. <label for="oauth2_key">{{.i18n.Tr "admin.auths.oauth2_clientID"}}</label>
  149. <input id="oauth2_key" name="oauth2_key" value="{{.oauth2_key}}">
  150. </div>
  151. <div class="required field">
  152. <label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label>
  153. <input id="oauth2_secret" name="oauth2_secret" value="{{.oauth2_secret}}">
  154. </div>
  155. </div>
  156. <div class="ldap field">
  157. <div class="ui checkbox">
  158. <label><strong>{{.i18n.Tr "admin.auths.attributes_in_bind"}}</strong></label>
  159. <input name="attributes_in_bind" type="checkbox" {{if .attributes_in_bind}}checked{{end}}>
  160. </div>
  161. </div>
  162. <div class="smtp inline field {{if not (eq .type 3)}}hide{{end}}">
  163. <div class="ui checkbox">
  164. <label><strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong></label>
  165. <input name="tls" type="checkbox" {{if .tls}}checked{{end}}>
  166. </div>
  167. </div>
  168. <div class="has-tls inline field {{if not .HasTLS}}hide{{end}}">
  169. <div class="ui checkbox">
  170. <label><strong>{{.i18n.Tr "admin.auths.skip_tls_verify"}}</strong></label>
  171. <input name="skip_verify" type="checkbox" {{if .skip_verify}}checked{{end}}>
  172. </div>
  173. </div>
  174. <div class="inline field">
  175. <div class="ui checkbox">
  176. <label><strong>{{.i18n.Tr "admin.auths.activated"}}</strong></label>
  177. <input name="is_active" type="checkbox" {{if .is_active}}checked{{end}}>
  178. </div>
  179. </div>
  180. <div class="field">
  181. <button class="ui green button">{{.i18n.Tr "admin.auths.new"}}</button>
  182. </div>
  183. </form>
  184. </div>
  185. <h4 class="ui top attached header">
  186. {{.i18n.Tr "admin.auths.tips"}}
  187. </h4>
  188. <div class="ui attached segment">
  189. <h5>GMail Settings:</h5>
  190. <p>Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true</p>
  191. <h5>OAuth GitHub:</h5>
  192. <p>{{.i18n.Tr "admin.auths.tip.github"}}</p>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. {{template "base/footer" .}}