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

Allow servers to send and receive messages directly #819

Merged
merged 5 commits into from Nov 29, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion server/auth.go
Expand Up @@ -229,7 +229,7 @@ func (s *Server) configureAuthorization() {
// checkAuthentication will check based on client type and
// return boolean indicating if client is authorized.
func (s *Server) checkAuthentication(c *client) bool {
switch c.typ {
switch c.kind {
case CLIENT:
return s.isClientAuthorized(c)
case ROUTER:
Expand Down Expand Up @@ -353,24 +353,31 @@ func (s *Server) isClientAuthorized(c *client) bool {
nkey = buildInternalNkeyUser(juc, acc)
c.RegisterNkeyUser(nkey)

// Generate an event if we have a system account.
s.accountConnectEvent(c)

// Check if we need to set an auth timer if the user jwt expires.
c.checkExpiration(juc.Claims())
return true
}

if nkey != nil {
if c.opts.Sig == "" {
c.Debugf("Signature missing")
return false
}
sig, err := base64.StdEncoding.DecodeString(c.opts.Sig)
if err != nil {
c.Debugf("Signature not valid base64")
return false
}
pub, err := nkeys.FromPublicKey(c.opts.Nkey)
if err != nil {
c.Debugf("User nkey not valid: %v", err)
return false
}
if err := pub.Verify(c.nonce, sig); err != nil {
c.Debugf("Signature not verified")
return false
}
c.RegisterNkeyUser(nkey)
Expand Down