This commit is contained in:
Jeff Mitchell 2016-08-19 16:48:32 -04:00
parent 840774a095
commit 2860dcc60f
16 changed files with 35 additions and 37 deletions

View file

@ -33,7 +33,7 @@ using the same name as specified here.`,
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.DeleteOperation: b.pathCRLDelete,
logical.ReadOperation: b.pathCRLRead,
logical.UpdateOperation: b.pathCRLWrite,
logical.UpdateOperation: b.pathCRLWrite,
},
HelpSynopsis: pathCRLsHelpSyn,

View file

@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathLeaseRead,
logical.ReadOperation: b.pathLeaseRead,
logical.UpdateOperation: b.pathLeaseWrite,
},

View file

@ -80,7 +80,7 @@ func (b *backend) pathConnectionWrite(req *logical.Request, data *framework.Fiel
// Store it
entry, err := logical.StorageEntryJSON("config/connection", connectionConfig{
URI: uri,
URI: uri,
})
if err != nil {
return nil, err
@ -99,7 +99,7 @@ func (b *backend) pathConnectionWrite(req *logical.Request, data *framework.Fiel
}
type connectionConfig struct {
URI string `json:"uri" structs:"uri" mapstructure:"uri"`
URI string `json:"uri" structs:"uri" mapstructure:"uri"`
}
const pathConfigConnectionHelpSyn = `

View file

@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathLeaseRead,
logical.ReadOperation: b.pathLeaseRead,
logical.UpdateOperation: b.pathLeaseWrite,
},

View file

@ -26,7 +26,7 @@ valid; defaults to 72 hours`,
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathCRLRead,
logical.ReadOperation: b.pathCRLRead,
logical.UpdateOperation: b.pathCRLWrite,
},

View file

@ -24,7 +24,7 @@ func pathConfigLease(b *backend) *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathLeaseRead,
logical.ReadOperation: b.pathLeaseRead,
logical.UpdateOperation: b.pathLeaseWrite,
},

View file

@ -91,7 +91,6 @@ func (b *backend) secretCredsRevoke(
}
username, ok := usernameRaw.(string)
// Get our connection
db, err := b.DB(req.Storage)
if err != nil {

View file

@ -25,7 +25,7 @@ func pathConfigZeroAddress(b *backend) *framework.Path {
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: b.pathConfigZeroAddressWrite,
logical.UpdateOperation: b.pathConfigZeroAddressWrite,
logical.ReadOperation: b.pathConfigZeroAddressRead,
logical.DeleteOperation: b.pathConfigZeroAddressDelete,
},

View file

@ -27,7 +27,7 @@ func pathKeys(b *backend) *framework.Path {
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: b.pathKeysWrite,
logical.UpdateOperation: b.pathKeysWrite,
logical.DeleteOperation: b.pathKeysDelete,
},
HelpSynopsis: pathKeysSyn,

View file

@ -22,7 +22,7 @@ func DuoPaths() []*framework.Path {
// DuoRootPaths returns the paths that are used to configure Duo.
func DuoRootPaths() []string {
return []string {
return []string{
"duo/access",
"duo/config",
}
@ -60,10 +60,10 @@ func DuoHandler(req *logical.Request, d *framework.FieldData, resp *logical.Resp
type duoAuthRequest struct {
successResp *logical.Response
username string
method string
passcode string
ipAddr string
username string
method string
passcode string
ipAddr string
}
func duoHandler(duoConfig *DuoConfig, duoAuthClient AuthClient, request *duoAuthRequest) (

View file

@ -34,7 +34,7 @@ func pathDuoAccess() *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: pathDuoAccessWrite,
logical.UpdateOperation: pathDuoAccessWrite,
},
HelpSynopsis: pathDuoAccessHelpSyn,

View file

@ -13,7 +13,7 @@ func pathDuoConfig() *framework.Path {
Pattern: `duo/config`,
Fields: map[string]*framework.FieldSchema{
"user_agent": &framework.FieldSchema{
Type: framework.TypeString,
Type: framework.TypeString,
Description: "User agent to connect to Duo (default \"\")",
},
"username_format": &framework.FieldSchema{
@ -24,7 +24,7 @@ func pathDuoConfig() *framework.Path {
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: pathDuoConfigWrite,
logical.ReadOperation: pathDuoConfigRead,
logical.ReadOperation: pathDuoConfigRead,
},
HelpSynopsis: pathDuoConfigHelpSyn,
@ -87,7 +87,7 @@ func pathDuoConfigRead(
type DuoConfig struct {
UsernameFormat string `json:"username_format"`
UserAgent string `json:"user_agent"`
UserAgent string `json:"user_agent"`
}
const pathDuoConfigHelpSyn = `

View file

@ -35,7 +35,7 @@ func MFARootPaths() []string {
}
// HandlerFunc is the callback called to handle MFA for a login request.
type HandlerFunc func (*logical.Request, *framework.FieldData, *logical.Response) (*logical.Response, error)
type HandlerFunc func(*logical.Request, *framework.FieldData, *logical.Response) (*logical.Response, error)
// handlers maps each supported MFA type to its handler.
var handlers = map[string]HandlerFunc{
@ -52,7 +52,7 @@ func wrapLoginPath(b *backend, loginPath *framework.Path) *framework.Path {
Description: "One time passcode (optional)",
}
loginPath.Fields["method"] = &framework.FieldSchema{
Type: framework.TypeString,
Type: framework.TypeString,
Description: "Multi-factor auth method to use (optional)",
}
// wrap write callback to do MFA after auth
@ -62,9 +62,9 @@ func wrapLoginPath(b *backend, loginPath *framework.Path) *framework.Path {
}
func (b *backend) wrapLoginHandler(loginHandler framework.OperationFunc) framework.OperationFunc {
return func (req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
return func(req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
// login with original login function first
resp, err := loginHandler(req, d);
resp, err := loginHandler(req, d)
if err != nil || resp.Auth == nil {
return resp, err
}

View file

@ -16,8 +16,8 @@ func pathMFAConfig(b *backend) *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: b.pathMFAConfigWrite,
logical.ReadOperation: b.pathMFAConfigRead,
logical.UpdateOperation: b.pathMFAConfigWrite,
logical.ReadOperation: b.pathMFAConfigRead,
},
HelpSynopsis: pathMFAConfigHelpSyn,

View file

@ -1,24 +1,23 @@
package logical
type HTTPCodedError interface {
Error() string
Code() int
Error() string
Code() int
}
func CodedError(c int, s string) HTTPCodedError {
return &codedError{s,c}
return &codedError{s, c}
}
type codedError struct {
s string
code int
s string
code int
}
func (e *codedError) Error() string {
return e.s
return e.s
}
func (e *codedError) Code() int {
return e.code
return e.code
}

View file

@ -20,7 +20,7 @@ type PostgreSQLBackend struct {
get_query string
delete_query string
list_query string
logger *log.Logger
logger *log.Logger
}
// newPostgreSQLBackend constructs a PostgreSQL backend using the given
@ -69,9 +69,9 @@ func newPostgreSQLBackend(conf map[string]string, logger *log.Logger) (Backend,
put_query: put_query,
get_query: "SELECT value FROM " + quoted_table + " WHERE path = $1 AND key = $2",
delete_query: "DELETE FROM " + quoted_table + " WHERE path = $1 AND key = $2",
list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" +
list_query: "SELECT key FROM " + quoted_table + " WHERE path = $1" +
"UNION SELECT substr(path, length($1)+1) FROM " + quoted_table + "WHERE parent_path = $1",
logger: logger,
logger: logger,
}
return m, nil
@ -154,7 +154,7 @@ func (m *PostgreSQLBackend) Delete(fullPath string) error {
func (m *PostgreSQLBackend) List(prefix string) ([]string, error) {
defer metrics.MeasureSince([]string{"postgres", "list"}, time.Now())
rows, err := m.client.Query(m.list_query, "/" + prefix)
rows, err := m.client.Query(m.list_query, "/"+prefix)
if err != nil {
return nil, err
}