Skip to content

Commit

Permalink
go-aah/aah#37 IsAuthSchemesConfigured method added
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Jul 15, 2017
1 parent f3c61dc commit e5b041b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion acrypto/password_encoder.go
Expand Up @@ -7,7 +7,14 @@ package acrypto
import "fmt"

// PasswordEncoder interface is used to encode and compare given hash and password
// based chosen hashing type. Such as `bcrypt`, `sha1`, `sha256`, `sha512` and `md5`.
// based chosen hashing type. Such as `bcrypt`, `scrypt`, `pbkdf2`, `sha1`, `sha256`,
// `sha512` and `md5`.
//
// Currently `bcrypt` is supported by aah framework, remaining encoders are `upcoming`.
//
// Caution: If you're using an unsecure hashing it may not be secured for your
// application. Consider using `bcrypt`, `scrypt`, or `pbkdf2`. Good read about
// hashing security - https://crackstation.net/hashing-security.htm
type PasswordEncoder interface {
Compare(hash, password []byte) bool
}
Expand Down
10 changes: 10 additions & 0 deletions security.go
Expand Up @@ -110,6 +110,16 @@ func (m *Manager) AddAuthScheme(name string, authScheme scheme.Schemer) error {
return nil
}

// IsAuthSchemesConfigured method true if one or more auth scheme is configured in
// security.conf under `security.auth_schemes { ... }`
func (m *Manager) IsAuthSchemesConfigured() bool {
return len(m.authSchemes) != 0
}

//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Package methods
//___________________________________

// AcquireSubject method gets the subject from pool.
func AcquireSubject() *Subject {
return subjectPool.Get().(*Subject)
Expand Down
1 change: 1 addition & 0 deletions security_test.go
Expand Up @@ -21,6 +21,7 @@ func TestSecurityInit(t *testing.T) {
sec := New()
err = sec.Init(cfg)
assert.Nil(t, err)
assert.True(t, sec.IsAuthSchemesConfigured())

// Add auth scheme
err = sec.AddAuthScheme("myauth", nil)
Expand Down

0 comments on commit e5b041b

Please sign in to comment.