forked from k2n/saml20-clj
-
Notifications
You must be signed in to change notification settings - Fork 11
/
specs.clj
72 lines (59 loc) · 2.09 KB
/
specs.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(ns saml20-clj.specs
(:require [clojure.spec.alpha :as s]
[saml20-clj.coerce :as coerce]
[saml20-clj.sp.metadata :as metadata]
[saml20-clj.sp.request :as request]
[saml20-clj.state :as state])
(:import java.net.URL
javax.security.cert.X509Certificate
org.opensaml.security.credential.Credential
org.w3c.dom.Element))
(defn url? [s]
(try
(URL. s)
true
(catch Exception _
false)))
(s/def ::acs-url url?)
(s/def ::idp-url url?)
(s/def ::issuer url?)
(s/def ::slo-url url?)
(s/def ::request-id string?)
(s/def ::sp-name string?)
(s/def ::app-name string?)
(s/def ::state-manager (partial satisfies? state/StateManager))
(s/def ::credential (partial instance? Credential))
(s/def ::instant inst?)
(s/def ::saml-request (partial satisfies? coerce/SerializeXMLString))
(s/def ::relay-state string?)
(s/def ::status int?)
(s/def ::headers map?)
(s/def ::body string?)
(s/def ::sp-cert (partial instance? X509Certificate))
(s/def ::requests-signed boolean?)
(s/def ::want-assertions-signed boolean?)
(s/def ::request (s/keys :req-un [::sp-name
::acs-url
::idp-url
::issuer]
:opt-un [::state-manager
::credential
::instant]))
(s/def ::ring-response (s/keys :req-un [::status ::headers ::body]))
(s/def ::metadata (s/keys :req-un [::acs-url
::app-name
::sp-cert]
:opt-un [::requests-signed
::slo-url
::want-assertions-signed]))
(s/fdef metadata/metadata
:args (s/cat :args ::metadata)
:ret string?)
(s/fdef request/request
:args (s/cat :request ::request)
:ret (partial instance? Element))
(s/fdef request/id-redirect-response
:args (s/cat :request ::saml-request
:idp-url ::idp-url
:relay-state ::relay-state)
:ret ::ring-response)