-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: accesss key * feat: access-key module & access-key cmds * fix: remove redunt error condition * opt: handle wrapper error and remove unused bucket type define in access-key module * feat: add daemon check before execute accesskey commands * optmize: access-key store prefix * optmize: not found error * feat: add s3 signature * chore: * chore: * chore: * chore: * chore: * feat: add store * chore: * feat: s3 access-key, server, handlers, statestore, filestore * chore: * optmize: code structure * style: s3 code structure * style: code structure * optmize: code structure * feat: add multiple context lock * feat: check auth * chore: * chore: * feat: add bucket service * chore: * mod: update bucket lock * chore: * chore: * chore: * del s3d * chore: s3 req & rsp structure * chore: * feat: add pubBucket api * feat: add more bucket api * chore: * chore: * feat: add request and response * chore: * feat: server build * chore: check acl * chore * chore: adjust bucket url * � * feat: add auth middleware * feat: adjust code structure * optmize: code structure & auth bug * feat: put object * chore: * mod: mod bucket parse req * optmize: adjust place of response error * chore: mig sig 01 * chore: clear sig * chore: mig sig 02 * chore: mig sig 03 * chore: mig sig 04 * optmize: refractor codes * optmize: rename auth to sign * optmize: code structure & h.name * fix: h.name * feat: put-object * feat: multipart * fix: nslock key * chore: rename s3 constructor file name * fix: tidy example go-ipfs-as-a-library go mod * chore: change default s3 server address to local * mod: add object api * feat: s3-compatible-api - 1. add start option and configure; 2. optmize providers interfaces and implements; 3. rewrite the server construct function * merge: object * chore: add object lock * chore: of delete objs * chore: * fix: list objects bug * chore: rename ListObjetV1Handler to ListObjectHandler, rename BTFS-Hash to CID * refractor: bucket service * refactor: object service * refractor: refract object service * refractor: handlers * refractor: bucket handler * refractor: bucket handler * refractor: response * refractor: response func * refractor: response * refractor: object * refractor: object * refractor: objects * refractor: btf api add timeout & add cid refs to enable referred cid can not be deleted * ref: fix delete object remove body * ref: format code * fix: routers * fix: add cors header * fix: router option * feat: add delete objects handler * refractor: multipart * ref: multipart * fix: multipart etag calculation * chore: add min part size todo * chore: upgrade 'github.com/anacrolix/torrent' from v1.47.0 to v1.52.5 * opt: comment and amz header * opt: code * opt: preflight cache max age * feat: bucket response add acl header * opt: change cid-list header to cid * fix: required check exlude unknow location * fix: get object acl * ref: requests * ref: complete refractor * fix: args parse * fix: get object unlock * fix: object acl writer * fix: delete objects error * fix: Sign handler name * fix: object name escape * fix: copy source validate * opt: s3 log * opt: s3 api log * fix: allow Cache-Control header in PutObject and CopyObject Action * opt: add access-key command taglines * opt: add accesskey command description * chore: add accesskey commands test path * chore: add accesskey test path --------- Co-authored-by: fish <[email protected]>
- Loading branch information
Showing
94 changed files
with
13,374 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
package commands | ||
|
||
import ( | ||
"errors" | ||
cmds "github.com/bittorrent/go-btfs-cmds" | ||
"github.com/bittorrent/go-btfs/core/commands/cmdenv" | ||
"github.com/bittorrent/go-btfs/s3/api/services/accesskey" | ||
) | ||
|
||
var AccessKeyCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Manage S3-Compatible-API access-keys.", | ||
ShortDescription: "Commands for generate, update, get and list access-keys stored in this node.", | ||
}, | ||
Subcommands: map[string]*cmds.Command{ | ||
"generate": accessKeyGenerateCmd, | ||
"enable": accessKeyEnableCmd, | ||
"disable": accessKeyDisableCmd, | ||
"reset": accessKeyResetCmd, | ||
"delete": accessKeyDeleteCmd, | ||
"get": accessKeyGetCmd, | ||
"list": accessKeyListCmd, | ||
}, | ||
NoLocal: true, | ||
} | ||
|
||
func checkDaemon(env cmds.Environment) (err error) { | ||
node, err := cmdenv.GetNode(env) | ||
if err != nil { | ||
return | ||
} | ||
if !node.IsDaemon { | ||
err = errors.New("please start the node first") | ||
} | ||
return | ||
} | ||
|
||
var accessKeyGenerateCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Generate a new access-key record.", | ||
ShortDescription: "Outputs the new created access-key record.", | ||
}, | ||
Arguments: []cmds.Argument{}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
ack, err := accesskey.Generate() | ||
if err != nil { | ||
return | ||
} | ||
err = cmds.EmitOnce(res, ack) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyEnableCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Set status of the specified access-key to enable.", | ||
ShortDescription: "Outputs empty if the access-key has been set to enable or it was already enabled.", | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("key", true, true, "The key").EnableStdin(), | ||
}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
key := req.Arguments[0] | ||
err = accesskey.Enable(key) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyDisableCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Set status of the specified access-key to enable.", | ||
ShortDescription: "Outputs empty if the access-key has been set to disable or it was already disabled.", | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("key", true, true, "The key").EnableStdin(), | ||
}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
key := req.Arguments[0] | ||
err = accesskey.Disable(key) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyResetCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Rest secret of the specified access-key.", | ||
ShortDescription: "Outputs the updated access-key record if it's secret has been reset.", | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("key", true, true, "The key").EnableStdin(), | ||
}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
key := req.Arguments[0] | ||
err = accesskey.Reset(key) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyDeleteCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Delete the specified access-key", | ||
ShortDescription: "Outputs empty if access-key record has been deleted.", | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("key", true, true, "The key").EnableStdin(), | ||
}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
key := req.Arguments[0] | ||
err = accesskey.Delete(key) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyGetCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Get an access-key detail info.", | ||
ShortDescription: "Outputs access-key record for the specified key.", | ||
}, | ||
Arguments: []cmds.Argument{ | ||
cmds.StringArg("key", true, true, "The key").EnableStdin(), | ||
}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
key := req.Arguments[0] | ||
ack, err := accesskey.Get(key) | ||
if err != nil { | ||
return | ||
} | ||
err = cmds.EmitOnce(res, ack) | ||
return | ||
}, | ||
} | ||
|
||
var accessKeyListCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "List all access-keys.", | ||
ShortDescription: "Outputs all non-deleted access-keys stored in current node.", | ||
}, | ||
Arguments: []cmds.Argument{}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) (err error) { | ||
err = checkDaemon(env) | ||
if err != nil { | ||
return | ||
} | ||
list, err := accesskey.List() | ||
if err != nil { | ||
return | ||
} | ||
err = cmds.EmitOnce(res, list) | ||
return | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.