mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: MacCloud/S3: step-113: support STS Temporary Security Token
This commit is contained in:
parent
9dd8223e0a
commit
da741beba6
5 changed files with 34 additions and 9 deletions
|
|
@ -105,15 +105,26 @@ procedure TAWSAuthSession.addNeededHeader( const request: NSMutableURLRequest );
|
|||
Exit;
|
||||
request.addValue_forHTTPHeaderField( request.URL.host, HttpConst.Header.Host );
|
||||
end;
|
||||
|
||||
procedure addTokenHeaderIfNeeded;
|
||||
begin
|
||||
if _accessKey.token = EmptyStr then
|
||||
Exit;
|
||||
request.addValue_forHTTPHeaderField(
|
||||
StringToNSString(_accessKey.token),
|
||||
NSSTR(AWSConst.Header.SECURITY_TOKEN) );
|
||||
end;
|
||||
|
||||
begin
|
||||
addDateHeaderIfNeeded;
|
||||
addHostHeaderIfNeeded;
|
||||
addTokenHeaderIfNeeded;
|
||||
end;
|
||||
|
||||
constructor TAWSAuthSession.Create( const params: TAWSAuthSessionParams );
|
||||
begin
|
||||
_params:= params;
|
||||
_accessKey:= TAWSAccessKey.Create( '', '' );
|
||||
_accessKey:= TAWSAccessKey.Create( '', '', '' );
|
||||
end;
|
||||
|
||||
destructor TAWSAuthSession.Destroy;
|
||||
|
|
|
|||
|
|
@ -36,11 +36,13 @@ type
|
|||
private
|
||||
_id: String;
|
||||
_secret: String;
|
||||
_token: String;
|
||||
public
|
||||
constructor Create( const id: String; const secret: String );
|
||||
constructor Create( const id: String; const secret: String; const token: String );
|
||||
function clone: TAWSAccessKey;
|
||||
property id: String read _id;
|
||||
property secret: String read _secret;
|
||||
property token: String read _token;
|
||||
end;
|
||||
|
||||
{ TAWSConnectionData }
|
||||
|
|
@ -65,6 +67,7 @@ type
|
|||
|
||||
TAWSConstHeader = record
|
||||
DATE: String;
|
||||
SECURITY_TOKEN: String;
|
||||
COPY_SOURCE: String;
|
||||
CONTENT_SHA256: String;
|
||||
CONTENT_SHA256_DEFAULT_VALUE: String;
|
||||
|
|
@ -80,6 +83,7 @@ const
|
|||
AWSConst: TAWSConst = (
|
||||
HEADER: (
|
||||
DATE: 'x-amz-date';
|
||||
SECURITY_TOKEN: 'x-amz-security-token';
|
||||
COPY_SOURCE: 'x-amz-copy-source';
|
||||
CONTENT_SHA256: 'x-amz-content-sha256';
|
||||
CONTENT_SHA256_DEFAULT_VALUE: 'UNSIGNED-PAYLOAD';
|
||||
|
|
@ -104,15 +108,16 @@ end;
|
|||
|
||||
{ TAWSAccessKey }
|
||||
|
||||
constructor TAWSAccessKey.Create( const id: String; const secret: String );
|
||||
constructor TAWSAccessKey.Create( const id: String; const secret: String; const token: String );
|
||||
begin
|
||||
_id:= id;
|
||||
_secret:= secret;
|
||||
_token:= token;
|
||||
end;
|
||||
|
||||
function TAWSAccessKey.clone: TAWSAccessKey;
|
||||
begin
|
||||
Result:= TAWSAccessKey.Create( _id, _secret );
|
||||
Result:= TAWSAccessKey.Create( _id, _secret, _token );
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ type
|
|||
_endPointTextField: NSTextField;
|
||||
_accessKeyIDTextField: NSTextField;
|
||||
_accessKeySecretTextField: NSTextField;
|
||||
_accessKeyTokenTextField: NSTextField;
|
||||
_accessKeySecretPlainTextField: NSTextField;
|
||||
_bucketTextField: NSTextField;
|
||||
_secretButton: NSButton;
|
||||
|
|
@ -222,6 +223,7 @@ begin
|
|||
_endPointTextField.setStringValue( StringToNSString(connectionData.endPoint) );
|
||||
_accessKeyIDTextField.setStringValue( StringToNSString(accessKey.id) );
|
||||
_accessKeySecretTextField.setStringValue( StringToNSString(accessKey.secret) );
|
||||
_accessKeyTokenTextField.setStringValue( StringToNSString(accessKey.token) );
|
||||
_bucketTextField.setStringValue( StringToNSString(connectionData.defaultBucket) );
|
||||
regionIndex:= _regionItems.indexOfRegion( _regionTextField.stringValue );
|
||||
if regionIndex >= 0 then
|
||||
|
|
@ -251,7 +253,8 @@ begin
|
|||
|
||||
accessKey:= TAWSAccessKey.Create(
|
||||
_accessKeyIDTextField.stringValue.UTF8String,
|
||||
_accessKeySecretTextField.stringValue.UTF8String );
|
||||
_accessKeySecretTextField.stringValue.UTF8String,
|
||||
_accessKeyTokenTextField.stringValue.UTF8String );
|
||||
client.setAccessKey( accessKey );
|
||||
|
||||
_controller.saveConnection( _nameTextField.stringValue );
|
||||
|
|
@ -324,10 +327,13 @@ begin
|
|||
self.addSubview( _secretButton );
|
||||
_secretButton.release;
|
||||
|
||||
addLabel( 'Bucket:', NSMakeRect(20,240,120,20) );
|
||||
_bucketTextField:= addTextField( NSMakeRect(146,240,250,22) );
|
||||
addLabel( 'Temporary Token:', NSMakeRect(20,240,120,20) );
|
||||
_accessKeyTokenTextField:= addTextField( NSMakeRect(146,240,250,22) );
|
||||
|
||||
_saveButton:= NSButton.alloc.initWithFrame( NSMakeRect(200,200,100,22) );
|
||||
addLabel( 'Bucket:', NSMakeRect(20,200,120,20) );
|
||||
_bucketTextField:= addTextField( NSMakeRect(146,200,250,22) );
|
||||
|
||||
_saveButton:= NSButton.alloc.initWithFrame( NSMakeRect(200,160,100,22) );
|
||||
_saveButton.setBezelStyle( NSRoundedBezelStyle );
|
||||
_saveButton.setTitle( NSSTR('Save') );
|
||||
_saveButton.setTarget( self );
|
||||
|
|
|
|||
|
|
@ -278,7 +278,8 @@ begin
|
|||
jsonAccessKey:= TJsonUtil.getDictionary( params, 'accessKey' );
|
||||
accessKey:= TS3AccessKey.Create(
|
||||
TJsonUtil.getString( jsonAccessKey, 'id' ),
|
||||
TJsonUtil.getString( jsonAccessKey, 'secret' )
|
||||
TJsonUtil.getString( jsonAccessKey, 'secret' ),
|
||||
TJsonUtil.getString( jsonAccessKey, 'token' )
|
||||
);
|
||||
TS3Client(driver).setAccessKey( accessKey );
|
||||
end;
|
||||
|
|
@ -295,6 +296,7 @@ begin
|
|||
jsonAccessKey:= NSMutableDictionary.new;
|
||||
TJsonUtil.setString( jsonAccessKey, 'id', accessKey.id );
|
||||
TJsonUtil.setString( jsonAccessKey, 'secret', accessKey.secret );
|
||||
TJsonUtil.setString( jsonAccessKey, 'token', accessKey.token );
|
||||
TJsonUtil.setDictionary( params, 'accessKey', jsonAccessKey );
|
||||
jsonAccessKey.release;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
Yandex
|
||||
One Drive
|
||||
Box
|
||||
Amazon S3 and Compatible
|
||||
2. other cloud drivers will be gradually supported
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue