forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip, making dcos spark secret command (apache#234)
[SPARK-601] Test RPC authentication, allow users to generate a secret client-side
- Loading branch information
Arthur Rand
authored
Dec 13, 2017
1 parent
bd2cb26
commit 6a99371
Showing
5 changed files
with
114 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/base64" | ||
) | ||
|
||
const KEYLENGTH = 128 | ||
|
||
func generateRandomBytes(n int) ([]byte, error) { | ||
// https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/ | ||
b := make([]byte, n) | ||
_, err := rand.Read(b) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return b, nil | ||
} | ||
|
||
func GetRandomStringSecret() (string, error) { | ||
b, err := generateRandomBytes(KEYLENGTH) | ||
return base64.URLEncoding.EncodeToString(b), err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters