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

Ev/tsh ssh 173 #176

Merged
merged 6 commits into from
Feb 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ export GO15VENDOREXPERIMENT=1

.PHONY: install test test-with-etcd remove-temp files test-package update test-grep-package cover-package cover-package-with-etcd run profile sloccount set-etcd install-assets docs-serve

##
## Ev:
##
.PHONY: newtsh
newtsh:
go build -o $(OUT)/t -i github.com/gravitational/teleport/tool/t

.PHONY: login
login:
out/tsh ssh --proxy-user=ekontsevoy ekontsevoy@edsger:3022 --web-proxy=edsger:3080

#
# Default target: builds all 3 executables and plaaces them in a current directory
#
Expand Down Expand Up @@ -42,13 +53,16 @@ production: clean
$(MAKE) -C build.assets



#
# tests everything: called by Jenkins
#
test:
go test -v github.com/gravitational/teleport/lib/client
go test -v github.com/gravitational/teleport/tool/t/...
go test -v github.com/gravitational/teleport/lib/... -cover
go test -v github.com/gravitational/teleport/tool/teleport... -cover
go test -v github.com/gravitational/teleport/tool/tsh -cover
# go test -v github.com/gravitational/teleport/tool/tsh -cover


test-with-etcd: install
Expand Down
12 changes: 3 additions & 9 deletions lib/auth/native/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/defaults"
"github.com/gravitational/teleport/lib/utils"

log "github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -146,8 +147,8 @@ func (n *nauth) GenerateHostCert(pkey, key []byte, hostname, authDomain string,
}

func (n *nauth) GenerateUserCert(pkey, key []byte, username string, ttl time.Duration) ([]byte, error) {
if (ttl > MaxCertDuration) || (ttl < MinCertDuration) {
return nil, trace.Errorf("wrong certificate ttl")
if (ttl > defaults.MaxCertDuration) || (ttl < defaults.MinCertDuration) {
return nil, trace.Errorf("wrong certificate TTL")
}
pubKey, _, _, _, err := ssh.ParseAuthorizedKey(key)
if err != nil {
Expand All @@ -174,10 +175,3 @@ func (n *nauth) GenerateUserCert(pkey, key []byte, username string, ttl time.Dur
}
return ssh.MarshalAuthorizedKey(cert), nil
}

const (
// MinCertDuration specifies minimum duration of validity of issued cert
MinCertDuration = time.Minute
// MaxCertDuration limits maximum duration of validity of issued cert
MaxCertDuration = 30 * time.Hour
)
4 changes: 4 additions & 0 deletions lib/auth/srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/session"

log "github.com/Sirupsen/logrus"

"github.com/codahale/lunk"
"github.com/gravitational/trace"
"github.com/julienschmidt/httprouter"
Expand Down Expand Up @@ -381,10 +383,12 @@ type generateUserCertReq struct {
func (s *APIServer) generateUserCert(w http.ResponseWriter, r *http.Request, _ httprouter.Params) (interface{}, error) {
var req *generateUserCertReq
if err := httplib.ReadJSON(r, &req); err != nil {
log.Errorf("failed parsing JSON request. %v", err)
return nil, trace.Wrap(err)
}
cert, err := s.a.GenerateUserCert(req.Key, req.User, req.TTL)
if err != nil {
log.Error(err)
return nil, trace.Wrap(err)
}
return string(cert), nil
Expand Down
Loading