mirror of
https://github.com/minio/minio.git
synced 2025-11-20 01:50:24 -05:00
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
This commit is contained in:
18
jwt.go
18
jwt.go
@@ -17,7 +17,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -28,8 +27,7 @@ import (
|
||||
|
||||
// JWT - jwt auth backend
|
||||
type JWT struct {
|
||||
accessKeyID []byte
|
||||
secretAccessKey []byte
|
||||
credential
|
||||
}
|
||||
|
||||
// Default - each token expires in 10hrs.
|
||||
@@ -40,13 +38,11 @@ const (
|
||||
// initJWT - initialize.
|
||||
func initJWT() *JWT {
|
||||
jwt := &JWT{}
|
||||
// Load credentials.
|
||||
config, err := loadConfigV2()
|
||||
fatalIf(err.Trace("JWT"), "Unable to load configuration file.", nil)
|
||||
|
||||
// Save access, secret keys.
|
||||
jwt.accessKeyID = []byte(config.Credentials.AccessKeyID)
|
||||
jwt.secretAccessKey = []byte(config.Credentials.SecretAccessKey)
|
||||
jwt.credential = serverConfig.GetCredential()
|
||||
|
||||
// Return.
|
||||
return jwt
|
||||
}
|
||||
|
||||
@@ -57,7 +53,7 @@ func (jwt *JWT) GenerateToken(userName string) (string, *probe.Error) {
|
||||
token.Claims["exp"] = time.Now().Add(time.Hour * tokenExpires).Unix()
|
||||
token.Claims["iat"] = time.Now().Unix()
|
||||
token.Claims["sub"] = userName
|
||||
tokenString, e := token.SignedString(jwt.secretAccessKey)
|
||||
tokenString, e := token.SignedString([]byte(jwt.SecretAccessKey))
|
||||
if e != nil {
|
||||
return "", probe.NewError(e)
|
||||
}
|
||||
@@ -68,9 +64,9 @@ func (jwt *JWT) GenerateToken(userName string) (string, *probe.Error) {
|
||||
func (jwt *JWT) Authenticate(userName, password string) bool {
|
||||
userName = strings.TrimSpace(userName)
|
||||
password = strings.TrimSpace(password)
|
||||
if !bytes.Equal([]byte(userName), jwt.accessKeyID) {
|
||||
if userName != jwt.AccessKeyID {
|
||||
return false
|
||||
}
|
||||
hashedPassword, _ := bcrypt.GenerateFromPassword(jwt.secretAccessKey, bcrypt.DefaultCost)
|
||||
hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(jwt.SecretAccessKey), bcrypt.DefaultCost)
|
||||
return bcrypt.CompareHashAndPassword(hashedPassword, []byte(password)) == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user