diff --git a/auth/jwt_auth.go b/auth/jwt_auth.go index 2d059f0..6fcbbc5 100644 --- a/auth/jwt_auth.go +++ b/auth/jwt_auth.go @@ -14,12 +14,9 @@ import ( ) // GetSignedJwtToken get a tokens signed with private key -func GetSignedJwtToken(appID string, privateKeyPath string) (string, error) { +func GetSignedJwtToken(appID string, privateKey string) (string, error) { - keyBytes, err := ioutil.ReadFile(privateKeyPath) - if err != nil { - return "", fmt.Errorf("unable to read private key path: %s, error: %s", privateKeyPath, err) - } + keyBytes := []byte(privateKey) key, keyErr := jwt.ParseRSAPrivateKeyFromPEM(keyBytes) if keyErr != nil { @@ -50,8 +47,8 @@ type JWTAuth struct { } // MakeAccessTokenForInstallation makes an access token for an installation / private key -func MakeAccessTokenForInstallation(appID string, installation int, privateKeyPath string) (string, error) { - signed, err := GetSignedJwtToken(appID, privateKeyPath) +func MakeAccessTokenForInstallation(appID string, installation int, privateKey string) (string, error) { + signed, err := GetSignedJwtToken(appID, privateKey) if err == nil { c := http.Client{} diff --git a/config/config.go b/config/config.go index c781abe..76ae1e5 100644 --- a/config/config.go +++ b/config/config.go @@ -54,8 +54,13 @@ func NewConfig() (Config, error) { if val, ok := os.LookupEnv("application_id"); ok && len(val) > 0 { config.ApplicationID = val + } else { + return config, fmt.Errorf("application_id must be given") } + // debug, _ := json.Marshal(config) + // fmt.Printf("Config:\n%s\n", debug) + return config, nil } diff --git a/derek.yml b/derek.yml index fb47008..125607f 100644 --- a/derek.yml +++ b/derek.yml @@ -5,7 +5,7 @@ provider: functions: derek: handler: ./ - image: alexellis/derek:0.6.3-rc1 + image: alexellis/derek:0.6.3-rc2 lang: dockerfile environment: debug: true