Merge pull request #1052 from nats-io/ro

Make ReadOperatorJWT public for embedded use case. Fixes #1050
This commit is contained in:
Derek Collison
2019-07-01 11:18:49 -07:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2018 The NATS Authors
// Copyright 2018-2019 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -28,8 +28,8 @@ var nscDecoratedRe = regexp.MustCompile(`\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:
// All JWTs once encoded start with this
const jwtPrefix = "eyJ"
// readOperatorJWT
func readOperatorJWT(jwtfile string) (*jwt.OperatorClaims, error) {
// ReadOperatorJWT will read a jwt file for an operator claim. This can be a decorated file.
func ReadOperatorJWT(jwtfile string) (*jwt.OperatorClaims, error) {
contents, err := ioutil.ReadFile(jwtfile)
if err != nil {
// Check to see if the JWT has been inlined.

View File

@@ -605,7 +605,7 @@ func (o *Options) ProcessConfigFile(configFile string) error {
// Assume for now these are file names, but they can also be the JWT itself inline.
o.TrustedOperators = make([]*jwt.OperatorClaims, 0, len(opFiles))
for _, fname := range opFiles {
opc, err := readOperatorJWT(fname)
opc, err := ReadOperatorJWT(fname)
if err != nil {
err := &configErr{tk, fmt.Sprintf("error parsing operator JWT: %v", err)}
errors = append(errors, err)