mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-04-20 16:20:52 +00:00
Let encrypt and decrypt be called by non-admins.
This commit is contained in:
@@ -191,7 +191,7 @@ func Summary(jsonIn []byte) ([]byte, error) {
|
||||
return jsonStatusError(errors.New("Vault is not created yet"))
|
||||
}
|
||||
|
||||
if err := validateAdmin(s.Name, s.Password); err != nil {
|
||||
if err := validateUser(s.Name, s.Password); err != nil {
|
||||
log.Printf("Error validating admin status of %s: %s", s.Name, err)
|
||||
return jsonStatusError(err)
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func Encrypt(jsonIn []byte) ([]byte, error) {
|
||||
return jsonStatusError(err)
|
||||
}
|
||||
|
||||
if err := validateAdmin(s.Name, s.Password); err != nil {
|
||||
if err := validateUser(s.Name, s.Password); err != nil {
|
||||
log.Println("Error validating admin status", err)
|
||||
return jsonStatusError(err)
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func TestEncryptDecrypt(t *testing.T) {
|
||||
t.Fatalf("Error in summary, %v", sum.Status)
|
||||
}
|
||||
|
||||
// Encrypt with non-admin (fail)
|
||||
// Encrypt with non-admin
|
||||
respJson, err = Encrypt(encryptJson)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in encrypt, %v", err)
|
||||
@@ -361,7 +361,7 @@ func TestEncryptDecrypt(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Error in encrypt, %v", err)
|
||||
}
|
||||
if s.Status == "ok" {
|
||||
if s.Status != "ok" {
|
||||
t.Fatalf("Error in encrypt, %v", s.Status)
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,7 @@ var indexHtml = []byte(`<!DOCTYPE html>
|
||||
<button type="submit" class="btn btn-primary">Delegate</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<hr />
|
||||
@@ -456,11 +457,11 @@ var indexHtml = []byte(`<!DOCTYPE html>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-6">
|
||||
<label for="encrypt-user-admin">Admin User</label>
|
||||
<label for="encrypt-user-admin">User name</label>
|
||||
<input type="text" name="Name" class="form-control" id="encrypt-user-admin" placeholder="User name" required />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="encrypt-user-pass">Admin Password</label>
|
||||
<label for="encrypt-user-pass">Password</label>
|
||||
<input type="password" name="Password" class="form-control" id="encrypt-user-pass" placeholder="Password" required />
|
||||
</div>
|
||||
</div>
|
||||
@@ -495,11 +496,11 @@ var indexHtml = []byte(`<!DOCTYPE html>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-6">
|
||||
<label for="decrypt-user-admin">Admin User</label>
|
||||
<label for="decrypt-user-admin">User name</label>
|
||||
<input type="text" name="Name" class="form-control" id="decrypt-user-admin" placeholder="User name" required />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="decrypt-user-pass">Admin Password</label>
|
||||
<label for="decrypt-user-pass">Password</label>
|
||||
<input type="password" name="Password" class="form-control" id="decrypt-user-pass" placeholder="Password" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user