mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-15 18:50:41 -07:00
Merge pull request #1052 from nats-io/ro
Make ReadOperatorJWT public for embedded use case. Fixes #1050
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user