Skip to content

Commit

Permalink
update: auth method
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Aug 24, 2023
1 parent 51f9953 commit a22f86e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ type auth struct {
// authenticate
// checks the user authentication.
func (a *auth) authenticate(token string) bool {
if a.username == " " || a.password == " " {
return true
}

parts := strings.Split(token, ":")

return parts[0] == a.username && parts[1] == a.password
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewServer(port string, metrics int, auth ...string) error {
)

// setting the authentication options
if len(auth) > 1 {
if len(auth) > 1 && auth[0] != "" && auth[1] != "" {
user = auth[0]
pass = auth[1]
} else {
Expand Down

0 comments on commit a22f86e

Please sign in to comment.