MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / New

Function New

internal/token/provider.go:73–100  ·  view source on GitHub ↗

New returns a new token provider

(cfg *config.Config, deps *Dependencies)

Source from the content-addressed store, hash-verified

71
72// New returns a new token provider
73func New(cfg *config.Config, deps *Dependencies) (Provider, error) {
74 if cfg.JWTType == "" {
75 deps.Log.Debug().Msg("missing jwt type")
76 return nil, fmt.Errorf("missing jwt type")
77 }
78 signingMethod := jwt.GetSigningMethod(cfg.JWTType)
79 switch signingMethod {
80 case jwt.SigningMethodHS256, jwt.SigningMethodHS384, jwt.SigningMethodHS512:
81 if cfg.JWTSecret == "" {
82 deps.Log.Debug().Msg("missing jwt secret")
83 return nil, fmt.Errorf("missing jwt secret")
84 }
85 case jwt.SigningMethodRS256, jwt.SigningMethodRS384, jwt.SigningMethodRS512,
86 jwt.SigningMethodES256, jwt.SigningMethodES384, jwt.SigningMethodES512:
87 if cfg.JWTPrivateKey == "" {
88 deps.Log.Debug().Msg("missing jwt private key")
89 return nil, fmt.Errorf("missing jwt private key")
90 }
91 if cfg.JWTPublicKey == "" {
92 deps.Log.Debug().Msg("missing jwt public key")
93 return nil, fmt.Errorf("missing jwt public key")
94 }
95 }
96 return &provider{
97 config: cfg,
98 dependencies: deps,
99 }, nil
100}

Callers 4

initFGATestSetupFunction · 0.92
initTestSetupFunction · 0.92
runRootFunction · 0.92
runMCPFunction · 0.92

Calls

no outgoing calls

Tested by 1

initFGATestSetupFunction · 0.74