parent
8bab21d795
commit
79ea34e70e
@ -0,0 +1,13 @@ |
|||||||
|
package auth |
||||||
|
|
||||||
|
type AuthenticationForm struct { |
||||||
|
Type int `form:"type"` |
||||||
|
Name string `form:"name" binding:"MaxSize(50)"` |
||||||
|
Domain string `form:"domain"` |
||||||
|
Host string `form:"host"` |
||||||
|
Port int `form:"port"` |
||||||
|
BaseDN string `form:"base_dn"` |
||||||
|
Attributes string `form:"attributes"` |
||||||
|
Filter string `form:"filter"` |
||||||
|
MsAdSA string `form:"ms_ad_sa"` |
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package admin |
||||||
|
|
||||||
|
import ( |
||||||
|
"strings" |
||||||
|
|
||||||
|
"github.com/gogits/gogs/models" |
||||||
|
"github.com/gogits/gogs/modules/auth" |
||||||
|
"github.com/gogits/gogs/modules/auth/ldap" |
||||||
|
"github.com/gogits/gogs/modules/middleware" |
||||||
|
"github.com/gpmgo/gopm/log" |
||||||
|
) |
||||||
|
|
||||||
|
func NewAuthSource(ctx *middleware.Context) { |
||||||
|
ctx.Data["Title"] = "New Authentication" |
||||||
|
ctx.Data["PageIsAuths"] = true |
||||||
|
ctx.HTML(200, "admin/auths/new") |
||||||
|
} |
||||||
|
|
||||||
|
func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { |
||||||
|
ctx.Data["Title"] = "New Authentication" |
||||||
|
ctx.Data["PageIsAuths"] = true |
||||||
|
|
||||||
|
if ctx.HasError() { |
||||||
|
ctx.HTML(200, "admin/auths/new") |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
u := &models.LDAPConfig{ |
||||||
|
Ldapsource: ldap.Ldapsource{ |
||||||
|
Host: form.Host, |
||||||
|
Port: form.Port, |
||||||
|
BaseDN: form.BaseDN, |
||||||
|
Attributes: form.Attributes, |
||||||
|
Filter: form.Filter, |
||||||
|
MsAdSAFormat: form.MsAdSA, |
||||||
|
Enabled: true, |
||||||
|
Name: form.Name, |
||||||
|
}, |
||||||
|
} |
||||||
|
|
||||||
|
if err := models.AddLDAPSource(form.Name, u); err != nil { |
||||||
|
switch err { |
||||||
|
default: |
||||||
|
ctx.Handle(500, "admin.auths.NewAuth", err) |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
log.Trace("%s Authentication created by admin(%s): %s", ctx.Req.RequestURI, |
||||||
|
ctx.User.LowerName, strings.ToLower(form.Name)) |
||||||
|
|
||||||
|
ctx.Redirect("/admin/auths") |
||||||
|
} |
||||||
|
|
||||||
|
func EditAuthSource(ctx *middleware.Context) { |
||||||
|
} |
||||||
|
|
||||||
|
func EditAuthSourcePost(ctx *middleware.Context) { |
||||||
|
} |
||||||
|
|
||||||
|
func DeleteAuthSource(ctx *middleware.Context) { |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
{{template "base/head" .}} |
||||||
|
{{template "base/navbar" .}} |
||||||
|
<div id="body" class="container" data-page="admin"> |
||||||
|
{{template "admin/nav" .}} |
||||||
|
<div id="admin-container" class="col-md-10"> |
||||||
|
<div class="panel panel-default"> |
||||||
|
<div class="panel-heading"> |
||||||
|
Authentication Management |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="panel-body"> |
||||||
|
<a href="/admin/auths/new" class="btn btn-primary">New Auth Source</a> |
||||||
|
<table class="table table-striped"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>Id</th> |
||||||
|
<th>Name</th> |
||||||
|
<th>Type</th> |
||||||
|
<th>Actived</th> |
||||||
|
<th>Updated</th> |
||||||
|
<th>Created</th> |
||||||
|
<th>Operation</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{{range .Sources}} |
||||||
|
<tr> |
||||||
|
<td>{{.Id}}</td> |
||||||
|
<td><a href="/admin/auths/{{.Id}}">{{.Name}}</a></td> |
||||||
|
<td>{{.Type}}</td> |
||||||
|
<td>{{.Actived}}</td> |
||||||
|
<td>{{DateFormat .Updated "M d, Y"}}</td> |
||||||
|
<td>{{DateFormat .Created "M d, Y"}}</td> |
||||||
|
<td><a href="/admin/users/{{.Id}}"><i class="fa fa-pencil-square-o"></i></a></td> |
||||||
|
</tr> |
||||||
|
{{end}} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{{template "base/footer" .}} |
@ -0,0 +1,93 @@ |
|||||||
|
{{template "base/head" .}} |
||||||
|
{{template "base/navbar" .}} |
||||||
|
<div id="body" class="container" data-page="admin"> |
||||||
|
{{template "admin/nav" .}} |
||||||
|
<div id="admin-container" class="col-md-9"> |
||||||
|
<div class="panel panel-default"> |
||||||
|
<div class="panel-heading"> |
||||||
|
New Authentication |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="panel-body"> |
||||||
|
<br/> |
||||||
|
<form action="/admin/auths/new" method="post" class="form-horizontal"> |
||||||
|
{{.CsrfTokenHtml}} |
||||||
|
{{template "base/alert" .}} |
||||||
|
<div class="form-group"> |
||||||
|
<label class="col-md-3 control-label">Auth Type: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<select class="form-control"> |
||||||
|
<option value=2>LDAP</option> |
||||||
|
<option value=3>SMTP</option> |
||||||
|
</select> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="form-group {{if .Err_UserName}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Name: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="name" class="form-control" placeholder="Type account's username" value="{{.username}}" required="required"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Domain: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Host: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Port: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Base DN: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Search Attributes: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Search Filter: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="form-group {{if .Err_Email}}has-error has-feedback{{end}}"> |
||||||
|
<label class="col-md-3 control-label">Ms Ad SA: </label> |
||||||
|
<div class="col-md-7"> |
||||||
|
<input name="domain" class="form-control" placeholder="Type account's e-mail address" value="{{.email}}" required="required" title="Email is not valid"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<hr/> |
||||||
|
<div class="form-group"> |
||||||
|
<div class="col-md-offset-3 col-md-7"> |
||||||
|
<button type="submit" class="btn btn-lg btn-primary">Create new authentication</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{{template "base/footer" .}} |
Loading…
Reference in new issue