-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the oauthConfig session secrets
- Loading branch information
Matt Rogers
committed
Nov 30, 2018
1 parent
ef3a065
commit 305f042
Showing
6 changed files
with
129 additions
and
2 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
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,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
namespace: openshift-kube-apiserver | ||
name: session-secret | ||
type: Opaque | ||
data: | ||
secrets: |
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,33 @@ | ||
package crypto | ||
|
||
import ( | ||
"crypto/rand" | ||
"crypto/sha256" | ||
) | ||
|
||
const ( | ||
sha256KeyLenBits = sha256.BlockSize * 8 // max key size with HMAC SHA256 | ||
aes256KeyLenBits = 256 // max key size with AES (AES-256) | ||
) | ||
|
||
func RandomAuthKeyBits() []byte { | ||
return randomBits(sha256KeyLenBits) | ||
} | ||
|
||
func RandomEncKeyBits() []byte { | ||
return randomBits(aes256KeyLenBits) | ||
} | ||
|
||
// randomBits returns a random byte slice with at least the requested bits of entropy. | ||
// Callers should avoid using a value less than 256 unless they have a very good reason. | ||
func randomBits(bits int) []byte { | ||
size := bits / 8 | ||
if bits%8 != 0 { | ||
size++ | ||
} | ||
b := make([]byte, size) | ||
if _, err := rand.Read(b); err != nil { | ||
panic(err) // rand should never fail | ||
} | ||
return b | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.