@@ -64,7 +64,16 @@ func (f *fuseOssfs2) PrecheckAuthConfig(o *Options, onNode bool) error {
6464 if features .FunctionalMutableFeatureGate .Enabled (features .RundCSIProtocol3 ) {
6565 return nil
6666 }
67- if o .SecretRef != "" {
67+ // Token authentication:
68+ // For runc scenarios, set the SecretRef parameter.
69+ runc := o .SecretRef != ""
70+ // For rund or eci scenarios, configure Token in nodePublishSecretRef or nodeStageSecretRef.
71+ // Expiration is not required for ossfs2.0
72+ rund := o .AccessKeyId != "" && o .AccessKeySecret != "" && o .SecurityToken != ""
73+ if runc && rund {
74+ return fmt .Errorf ("Token and secretRef cannot be set at the same time" )
75+ }
76+ if rund || runc {
6877 if o .AkID != "" || o .AkSecret != "" {
6978 return fmt .Errorf ("AK and secretRef cannot be set at the same time" )
7079 }
@@ -95,13 +104,26 @@ func (f *fuseOssfs2) MakeAuthConfig(o *Options, m metadata.MetadataProvider) (au
95104 case AuthTypeSTS :
96105 authCfg .RoleName = o .RoleName
97106 case "" :
107+ // fixed AKSK
108+ passwdFile := utils .GetPasswdFileName (f .Name ())
109+ if o .AkID != "" && o .AkSecret != "" {
110+ authCfg .Secrets = map [string ]string {
111+ utils .GetPasswdFileName (f .Name ()): fmt .Sprintf ("--oss_access_key_id=%s\n --oss_access_key_secret=%s" , o .AkID , o .AkSecret ),
112+ }
113+ return
114+ }
115+ // secretRef for RunC
98116 if o .SecretRef != "" {
99117 authCfg .SecretRef = o .SecretRef
100118 return
101119 }
120+ // token secret for RunD
102121 authCfg .Secrets = map [string ]string {
103- utils .GetPasswdFileName (f .Name ()): fmt .Sprintf ("--oss_access_key_id=%s\n --oss_access_key_secret=%s" , o .AkID , o .AkSecret ),
122+ filepath .Join (passwdFile , KeyAccessKeyId ): o .AccessKeyId ,
123+ filepath .Join (passwdFile , KeyAccessKeySecret ): o .AccessKeySecret ,
124+ filepath .Join (passwdFile , KeySecurityToken ): o .SecurityToken ,
104125 }
126+
105127 default :
106128 return nil , fmt .Errorf ("%s do not support authType: %s" , f .Name (), o .AuthType )
107129 }
@@ -162,14 +184,19 @@ func (f *fuseOssfs2) getAuthOptions(o *Options, region string) (mountOptions []s
162184 mountOptions = append (mountOptions , "ram_role=" + o .RoleName )
163185 }
164186 case "" :
187+ // fixed AKSK
188+ if o .AkID != "" && o .AkSecret != "" {
189+ // for aksk in secret, it will make passwd_file option in mount-proxy server as it's under a tempdir
190+ return
191+ }
165192 if o .SecretRef != "" {
166193 mountOptions = append (mountOptions ,
167194 fmt .Sprintf ("oss_sts_multi_conf_ak_file=%s" , filepath .Join (utils .GetConfigDir (o .FuseType ), utils .GetPasswdFileName (o .FuseType ), KeyAccessKeyId )),
168195 fmt .Sprintf ("oss_sts_multi_conf_sk_file=%s" , filepath .Join (utils .GetConfigDir (o .FuseType ), utils .GetPasswdFileName (o .FuseType ), KeyAccessKeySecret )),
169196 fmt .Sprintf ("oss_sts_multi_conf_token_file=%s" , filepath .Join (utils .GetConfigDir (o .FuseType ), utils .GetPasswdFileName (o .FuseType ), KeySecurityToken )),
170197 )
171198 }
172- // publishSecretRef will make option in mount-proxy server
199+ // for token in secret, it will make passwd_file option in mount-proxy server as it's under a tempdir
173200 default :
174201 return nil
175202 }
0 commit comments