Skip to content

Commit

Permalink
Fix jwt workdir.
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Jan 4, 2018
1 parent 5b7dd7e commit 794248f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"

jwt "github.com/dgrijalva/jwt-go"
Expand Down Expand Up @@ -62,11 +63,18 @@ func (j *jwtctx) ParseToken(token string) (*jwt.Token, error) {

// NewCtx initializes our jwt context. For now, it is expected that the pem files
// (private and public) are already in os.TempDir() + "/jwt/rsa/".
func NewCtx() (*jwtctx, error) {
func NewCtx(pemdir ...string) (*jwtctx, error) {
// TODO: transfer this to authd service

// Note: sesha3 uses /var/lib/sesha3 folder so calls to `NewCtx` from sesha3 should
// provide the correct pemdir value.
tmpdir := os.TempDir() + "/jwt/rsa/"
pempub := tmpdir + "token.pem.pub"
pemprv := tmpdir + "token.pem"
if len(pemdir) > 0 {
tmpdir = pemdir[0]
}

pempub := filepath.Join(tmpdir, "token.pem.pub")
pemprv := filepath.Join(tmpdir, "token.pem")

pubcache, err := ioutil.ReadFile(pempub)
if err != nil {
Expand Down

0 comments on commit 794248f

Please sign in to comment.