Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ravi/Aishwarya | Allow okta-config to be present outside the bundled jar #4

Merged
merged 1 commit into from Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions docs/coverage/index.html
Expand Up @@ -23,12 +23,12 @@
style="width:100.0%;
float:left;"> 18 </div></td>
<td class="with-number">100.00 %</td>
<td class="with-number">65</td><td class="with-number">18</td><td class="with-number">18</td>
<td class="with-number">65</td><td class="with-number">19</td><td class="with-number">18</td>
</tr>
<tr>
<td><a href="ring/ring_okta/predicates.clj.html">ring.ring-okta.predicates</a></td><td class="with-bar"><div class="covered"
style="width:100.0%;
float:left;"> 86 </div></td>
float:left;"> 90 </div></td>
<td class="with-number">100.00 %</td>
<td class="with-bar"><div class="covered"
style="width:100.0%;
Expand All @@ -38,23 +38,23 @@
</tr>
<tr>
<td><a href="ring/ring_okta/saml.clj.html">ring.ring-okta.saml</a></td><td class="with-bar"><div class="covered"
style="width:56.666666666666664%;
float:left;"> 17 </div><div class="not-covered"
style="width:43.333333333333336%;
float:left;"> 13 </div></td>
<td class="with-number">56.67 %</td>
style="width:60.0%;
float:left;"> 18 </div><div class="not-covered"
style="width:40.0%;
float:left;"> 12 </div></td>
<td class="with-number">60.00 %</td>
<td class="with-bar"><div class="covered"
style="width:54.54545454545455%;
style="width:60.0%;
float:left;"> 6 </div><div class="not-covered"
style="width:45.45454545454545%;
float:left;"> 5 </div></td>
<td class="with-number">54.55 %</td>
<td class="with-number">16</td><td class="with-number">2</td><td class="with-number">11</td>
style="width:40.0%;
float:left;"> 4 </div></td>
<td class="with-number">60.00 %</td>
<td class="with-number">15</td><td class="with-number">2</td><td class="with-number">10</td>
</tr>
<tr>
<td><a href="ring/ring_okta/session.clj.html">ring.ring-okta.session</a></td><td class="with-bar"><div class="covered"
style="width:100.0%;
float:left;"> 31 </div></td>
float:left;"> 27 </div></td>
<td class="with-number">100.00 %</td>
<td class="with-bar"><div class="covered"
style="width:100.0%;
Expand All @@ -64,9 +64,9 @@
</tr>
<tr><td>Totals:</td>
<td class="with-bar"></td>
<td class="with-number">94.76 %</td>
<td class="with-number">95.16 %</td>
<td class="with-bar"></td>
<td class="with-number">91.53 %</td>
<td class="with-number">93.10 %</td>
</tr>
</table>
</body>
Expand Down
8 changes: 4 additions & 4 deletions docs/coverage/ring/middleware/okta.clj.html
Expand Up @@ -128,10 +128,10 @@
041&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;:skip-routes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;a&nbsp;list&nbsp;of&nbsp;routes&nbsp;to&nbsp;skip&nbsp;Okta&nbsp;authentication
042&nbsp;&nbsp;&nbsp;&nbsp;:skip-routes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;a&nbsp;list&nbsp;of&nbsp;routes&nbsp;as&nbsp;a&nbsp;string&nbsp;or&nbsp;regex&nbsp;to&nbsp;skip&nbsp;Okta&nbsp;authentication
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.g.&nbsp;[:get&nbsp;\&quot;&#x2F;about\&quot;&nbsp;:any&nbsp;\&quot;&#x2F;contact\&quot;]
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.g.&nbsp;[:get&nbsp;\&quot;&#x2F;about\&quot;&nbsp;:any&nbsp;\&quot;&#x2F;contact\&quot;&nbsp;:get&nbsp;\&quot;&#x2F;home&#x2F;\\S+\&quot;]
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
044&nbsp;&nbsp;
Expand All @@ -151,8 +151,8 @@
<span class="covered" title="5 out of 5 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;([handler&nbsp;okta-home]&nbsp;(wrap-okta&nbsp;handler&nbsp;okta-home&nbsp;{}))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;
<span class="blank" title="0 out of 0 forms covered">
050&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;([handler&nbsp;okta-home&nbsp;{:keys&nbsp;[okta-config&nbsp;redirect-after-logout]
Expand Down
4 changes: 2 additions & 2 deletions docs/coverage/ring/ring_okta/predicates.clj.html
Expand Up @@ -61,8 +61,8 @@
<span class="covered" title="3 out of 3 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(=&nbsp;skip-method&nbsp;request-method))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(=&nbsp;skip-path&nbsp;request-path)))
<span class="covered" title="7 out of 7 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not-nil?&nbsp;(re-matches&nbsp;(re-pattern&nbsp;skip-path)&nbsp;request-path))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
021&nbsp;&nbsp;
Expand Down
27 changes: 12 additions & 15 deletions docs/coverage/ring/ring_okta/saml.clj.html
Expand Up @@ -20,37 +20,34 @@
005&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
006&nbsp;&nbsp;(defn-&nbsp;get-valid-user-id&nbsp;[saml-response&nbsp;okta-config]
006&nbsp;&nbsp;(defn-&nbsp;get-valid-user-id&nbsp;[saml-response&nbsp;okta-config&nbsp;validator]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[validator&nbsp;(SAMLValidator.)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;config&nbsp;(.getConfiguration&nbsp;validator&nbsp;okta-config)
<span class="not-covered" title="0 out of 3 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[config&nbsp;(.getConfiguration&nbsp;validator&nbsp;okta-config)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;decoded-saml-response&nbsp;(String.&nbsp;(b64&#x2F;decode&nbsp;(.getBytes&nbsp;saml-response&nbsp;&quot;UTF-8&quot;)))
008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;decoded-saml-response&nbsp;(String.&nbsp;(b64&#x2F;decode&nbsp;(.getBytes&nbsp;saml-response&nbsp;&quot;UTF-8&quot;)))
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;valid-saml-response&nbsp;(.getSAMLResponse&nbsp;validator&nbsp;decoded-saml-response&nbsp;config)]
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;valid-saml-response&nbsp;(.getSAMLResponse&nbsp;validator&nbsp;decoded-saml-response&nbsp;config)]
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(.getUserID&nbsp;valid-saml-response)))
010&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(.getUserID&nbsp;valid-saml-response)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
012&nbsp;&nbsp;
011&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
013&nbsp;&nbsp;(defn&nbsp;respond-to-okta-post&nbsp;[okta-config&nbsp;params]
012&nbsp;&nbsp;(defn&nbsp;respond-to-okta-post&nbsp;[okta-config&nbsp;params]
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;{:redirect-url&nbsp;(:RelayState&nbsp;params)
013&nbsp;&nbsp;&nbsp;&nbsp;{:redirect-url&nbsp;(:RelayState&nbsp;params)
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:authenticated-user-email&nbsp;(string&#x2F;lower-case
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:authenticated-user-email&nbsp;(string&#x2F;lower-case
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(get-valid-user-id&nbsp;(:SAMLResponse&nbsp;params)&nbsp;okta-config))})
<span class="covered" title="7 out of 7 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(get-valid-user-id&nbsp;(:SAMLResponse&nbsp;params)&nbsp;okta-config&nbsp;(SAMLValidator.)))})
</span><br/>
</body>
</html>
6 changes: 3 additions & 3 deletions docs/coverage/ring/ring_okta/session.clj.html
Expand Up @@ -23,10 +23,10 @@
006&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
007&nbsp;&nbsp;(defn&nbsp;login&nbsp;[{:keys&nbsp;[okta-config-location&nbsp;params]}]
007&nbsp;&nbsp;(defn&nbsp;login&nbsp;[{:keys&nbsp;[params&nbsp;okta-config-location]}]
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[okta-response&nbsp;(saml&#x2F;respond-to-okta-post&nbsp;(slurp&nbsp;(io&#x2F;resource&nbsp;okta-config-location))&nbsp;params)]
<span class="covered" title="5 out of 5 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[okta-response&nbsp;(saml&#x2F;respond-to-okta-post&nbsp;params&nbsp;okta-config-location)]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(assoc-in
Expand Down
2 changes: 1 addition & 1 deletion src/ring/ring_okta/session.clj
Expand Up @@ -5,7 +5,7 @@
[ring.util.response :as response]))

(defn login [{:keys [okta-config-location params]}]
(let [okta-response (saml/respond-to-okta-post (slurp (io/resource okta-config-location)) params)]
(let [okta-response (saml/respond-to-okta-post (with-open [r (io/reader okta-config-location)] (slurp r)) params)]
(assoc-in
(response/redirect-after-post (:redirect-url okta-response))
[:session :okta/user]
Expand Down
2 changes: 1 addition & 1 deletion test/ring/middleware/okta_test.clj
Expand Up @@ -10,7 +10,7 @@

(def okta-home "https://company.okta.com")
(def default-okta-config "okta-config.xml")
(def custom-okta-config "custom-okta-config.xml")
(def custom-okta-config "test-resources/custom-okta-config.xml")

(deftest test-wrap-okta
(let [default-handler #(response %)]
Expand Down
2 changes: 1 addition & 1 deletion test/ring/ring_okta/session_test.clj
Expand Up @@ -8,7 +8,7 @@
:authenticated-user-email "foo@bar.com"})

(deftest test-login
(let [request {:params {} :okta-config-location "okta-config.xml"}]
(let [request {:params {} :okta-config-location "test-resources/okta-config.xml"}]
(with-redefs [saml/respond-to-okta-post stub-respond-to-okta-post]
(testing "user placed in session"
(is (= "foo@bar.com" (-> (session/login request) :session :okta/user))))
Expand Down