@@ -175,7 +175,7 @@ func (c *Core) enableCredentialInternal(ctx context.Context, entry *MountEntry,
175175 var backend logical.Backend
176176 // Create the new backend
177177 sysView := c .mountEntrySysView (entry )
178- backend , entry . RunningSha256 , err = c .newCredentialBackend (ctx , entry , sysView , view )
178+ backend , err = c .newCredentialBackend (ctx , entry , sysView , view )
179179 if err != nil {
180180 return err
181181 }
@@ -188,14 +188,6 @@ func (c *Core) enableCredentialInternal(ctx context.Context, entry *MountEntry,
188188 if backendType != logical .TypeCredential {
189189 return fmt .Errorf ("cannot mount %q of type %q as an auth backend" , entry .Type , backendType )
190190 }
191- // update the entry running version with the configured version, which was verified during registration.
192- entry .RunningVersion = entry .Version
193- if entry .RunningVersion == "" {
194- // don't set the running version to a builtin if it is running as an external plugin
195- if entry .RunningSha256 == "" {
196- entry .RunningVersion = versions .GetBuiltinVersion (consts .PluginTypeCredential , entry .Type )
197- }
198- }
199191 addPathCheckers (c , entry , backend , viewPath )
200192
201193 // If the mount is filtered or we are on a DR secondary we don't want to
@@ -249,7 +241,7 @@ func (c *Core) enableCredentialInternal(ctx context.Context, entry *MountEntry,
249241 }
250242
251243 if c .logger .IsInfo () {
252- c .logger .Info ("enabled credential backend" , "path" , entry .Path , "type" , entry .Type , "version" , entry .Version )
244+ c .logger .Info ("enabled credential backend" , "path" , entry .Path , "type" , entry .Type , "version" , entry .RunningVersion )
253245 }
254246 return nil
255247}
@@ -805,29 +797,24 @@ func (c *Core) setupCredentials(ctx context.Context) error {
805797 // Initialize the backend
806798 sysView := c .mountEntrySysView (entry )
807799
808- backend , entry . RunningSha256 , err = c .newCredentialBackend (ctx , entry , sysView , view )
800+ backend , err = c .newCredentialBackend (ctx , entry , sysView , view )
809801 if err != nil {
810802 c .logger .Error ("failed to create credential entry" , "path" , entry .Path , "error" , err )
811803
812- if c .isMountable (ctx , entry , consts .PluginTypeCredential ) {
804+ mountable , checkErr := c .isMountable (ctx , entry , consts .PluginTypeSecrets )
805+ if checkErr != nil {
806+ return errors .Join (errLoadMountsFailed , checkErr , err )
807+ }
808+ if mountable {
813809 c .logger .Warn ("skipping plugin-based auth entry" , "path" , entry .Path )
814810 goto ROUTER_MOUNT
815811 }
816- return errLoadAuthFailed
812+ return errors . Join ( errLoadAuthFailed , err )
817813 }
818814 if backend == nil {
819815 return fmt .Errorf ("nil backend returned from %q factory" , entry .Type )
820816 }
821817
822- // update the entry running version with the configured version, which was verified during registration.
823- entry .RunningVersion = entry .Version
824- if entry .RunningVersion == "" {
825- // don't set the running version to a builtin if it is running as an external plugin
826- if entry .RunningSha256 == "" {
827- entry .RunningVersion = versions .GetBuiltinVersion (consts .PluginTypeCredential , entry .Type )
828- }
829- }
830-
831818 // Do not start up deprecated builtin plugins. If this is a major
832819 // upgrade, stop unsealing and shutdown. If we've already mounted this
833820 // plugin, skip backend initialization and mount the data for posterity.
@@ -953,33 +940,37 @@ func (c *Core) teardownCredentials(ctx context.Context) error {
953940
954941// newCredentialBackend is used to create and configure a new credential backend by name.
955942// It also returns the SHA256 of the plugin, if available.
956- func (c * Core ) newCredentialBackend (ctx context.Context , entry * MountEntry , sysView logical.SystemView , view logical.Storage ) (logical.Backend , string , error ) {
943+ func (c * Core ) newCredentialBackend (ctx context.Context , entry * MountEntry , sysView logical.SystemView , view logical.Storage ) (logical.Backend , error ) {
957944 t := entry .Type
958945 if alias , ok := credentialAliases [t ]; ok {
959946 t = alias
960947 }
961948
949+ pluginVersion , err := c .resolveMountEntryVersion (ctx , consts .PluginTypeCredential , entry )
950+ if err != nil {
951+ return nil , err
952+ }
962953 var runningSha string
963- f , ok := c .credentialBackends [t ]
954+ factory , ok := c .credentialBackends [t ]
964955 if ! ok {
965- plug , err := c .pluginCatalog .Get (ctx , t , consts .PluginTypeCredential , entry . Version )
956+ plug , err := c .pluginCatalog .Get (ctx , t , consts .PluginTypeCredential , pluginVersion )
966957 if err != nil {
967- return nil , "" , err
958+ return nil , err
968959 }
969960 if plug == nil {
970961 errContext := t
971- if entry . Version != "" {
972- errContext += fmt .Sprintf (", version=%s" , entry . Version )
962+ if pluginVersion != "" {
963+ errContext += fmt .Sprintf (", version=%s" , pluginVersion )
973964 }
974- return nil , "" , fmt .Errorf ("%w: %s" , plugincatalog .ErrPluginNotFound , errContext )
965+ return nil , fmt .Errorf ("%w: %s" , plugincatalog .ErrPluginNotFound , errContext )
975966 }
976967 if len (plug .Sha256 ) > 0 {
977968 runningSha = hex .EncodeToString (plug .Sha256 )
978969 }
979970
980- f = plugin .Factory
971+ factory = plugin .Factory
981972 if ! plug .Builtin {
982- f = wrapFactoryCheckPerms (c , plugin .Factory )
973+ factory = wrapFactoryCheckPerms (c , plugin .Factory )
983974 }
984975 }
985976 // Set up conf to pass in plugin_name
@@ -996,7 +987,7 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV
996987 }
997988
998989 conf ["plugin_type" ] = consts .PluginTypeCredential .String ()
999- conf ["plugin_version" ] = entry . Version
990+ conf ["plugin_version" ] = pluginVersion
1000991
1001992 authLogger := c .baseLogger .Named (fmt .Sprintf ("auth.%s.%s" , t , entry .Accessor ))
1002993 c .AddLogger (authLogger )
@@ -1005,11 +996,11 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV
1005996 MountAccessor : entry .Accessor ,
1006997 MountPath : entry .Path ,
1007998 Plugin : entry .Type ,
1008- PluginVersion : entry . RunningVersion ,
1009- Version : entry .Version ,
999+ PluginVersion : pluginVersion ,
1000+ Version : entry .Options [ "version" ] ,
10101001 })
10111002 if err != nil {
1012- return nil , "" , err
1003+ return nil , err
10131004 }
10141005
10151006 config := & logical.BackendConfig {
@@ -1021,12 +1012,19 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV
10211012 EventsSender : pluginEventSender ,
10221013 }
10231014
1024- b , err := f (ctx , config )
1015+ backend , err := factory (ctx , config )
10251016 if err != nil {
1026- return nil , "" , err
1017+ return nil , err
1018+ }
1019+ if backend != nil {
1020+ entry .RunningVersion = pluginVersion
1021+ entry .RunningSha256 = runningSha
1022+ if entry .RunningVersion == "" && entry .RunningSha256 == "" {
1023+ entry .RunningVersion = versions .GetBuiltinVersion (consts .PluginTypeCredential , entry .Type )
1024+ }
10271025 }
10281026
1029- return b , runningSha , nil
1027+ return backend , nil
10301028}
10311029
10321030func wrapFactoryCheckPerms (core * Core , f logical.Factory ) logical.Factory {
0 commit comments