summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2017-09-19 04:39:36 +0000
committerMike Crute <mike@crute.us>2017-09-19 04:39:36 +0000
commit9f7861ffe1397da514606b189f5b3e383f4e7ed7 (patch)
tree2bd145745efba52ac136166e4f4535cfd59359ea /util.go
parentb7867d9cf5b0dd175b8167a552b830ebfe47d0ed (diff)
downloadoidc_proxy-9f7861ffe1397da514606b189f5b3e383f4e7ed7.tar.bz2
oidc_proxy-9f7861ffe1397da514606b189f5b3e383f4e7ed7.tar.xz
oidc_proxy-9f7861ffe1397da514606b189f5b3e383f4e7ed7.zip
Finish out most of the proxy functionality
Diffstat (limited to 'util.go')
-rw-r--r--util.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.go b/util.go
index 10709e2..7385dfd 100644
--- a/util.go
+++ b/util.go
@@ -1,6 +1,8 @@
1package main 1package main
2 2
3import ( 3import (
4 "crypto/sha256"
5 "encoding/hex"
4 "net/url" 6 "net/url"
5 "strings" 7 "strings"
6) 8)
@@ -41,3 +43,19 @@ func URLMustParse(u string) *url.URL {
41func CompareUpper(lhs, rhs string) bool { 43func CompareUpper(lhs, rhs string) bool {
42 return strings.ToUpper(lhs) == strings.ToUpper(rhs) 44 return strings.ToUpper(lhs) == strings.ToUpper(rhs)
43} 45}
46
47func HostFromURL(u string) string {
48 o, err := url.Parse(u)
49 if err != nil {
50 return ""
51 }
52
53 h := strings.Split(o.Host, ":")
54 return h[0]
55}
56
57func Sha256Hex(v string) string {
58 s256 := sha256.New()
59 s256.Write([]byte(v))
60 return hex.EncodeToString(s256.Sum(nil))
61}