summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2017-09-05 03:52:50 +0000
committerMike Crute <mike@crute.us>2017-09-05 03:52:50 +0000
commitb7867d9cf5b0dd175b8167a552b830ebfe47d0ed (patch)
tree4b52c7461c7d9c48d68bec78cac6d06ae5940d28 /util.go
parent34d0f2d7e323acdc48cf91b0dc8514b6753de5d5 (diff)
downloadoidc_proxy-b7867d9cf5b0dd175b8167a552b830ebfe47d0ed.tar.bz2
oidc_proxy-b7867d9cf5b0dd175b8167a552b830ebfe47d0ed.tar.xz
oidc_proxy-b7867d9cf5b0dd175b8167a552b830ebfe47d0ed.zip
Finish JWS and Cert validation
Diffstat (limited to 'util.go')
-rw-r--r--util.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..10709e2
--- /dev/null
+++ b/util.go
@@ -0,0 +1,43 @@
1package main
2
3import (
4 "net/url"
5 "strings"
6)
7
8type stringSet struct {
9 values map[string]bool
10}
11
12func NewStringSet(values ...string) *stringSet {
13 s := &stringSet{
14 values: make(map[string]bool, len(values)),
15 }
16
17 for _, v := range values {
18 s.Add(v)
19 }
20
21 return s
22}
23
24func (s *stringSet) Add(v string) {
25 s.values[v] = true
26}
27
28func (s *stringSet) Contains(k string) bool {
29 _, ok := s.values[k]
30 return ok
31}
32
33func URLMustParse(u string) *url.URL {
34 o, err := url.Parse(u)
35 if err != nil {
36 panic(err)
37 }
38 return o
39}
40
41func CompareUpper(lhs, rhs string) bool {
42 return strings.ToUpper(lhs) == strings.ToUpper(rhs)
43}