Skip to content

BYU-ODH/byu-ws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

byu-ws

A very light-weight Clojure library facilitating BYU web service requests. Takes care of nonce encoding and header generation for requests.

Usage

Nonce encoding

Exposes the get-http-authorization-header function, which currently works with Nonce verification. Is aware of the URLs for the student record service and the student schedule service (though you will need appropriate credentials and privileges granted to make these work).

To get the :authorization header you want to send with your web service request, do something like the following:

(get-http-authorization-header {:api-key "your api key"
                                :shared-secret "your shared secret"
                                :key-type "API"
                                :encoding-type "Nonce"
                                :url (byu-ws.core/SERVICE-URLS :records) ; or :schedule, etc
                                        ; url will need to be modified appropriately for the web service (schedule adds personid/yearterm for example)
                                :request-body "" ; blank by default
                                :actor some-netid ; netid of person in question
                                :content-type "application/json"
                                :http-method "GET"
                                :actor-in-hash true
                                })

Oauth2 Use

Currently this takes you as far as receiving your oauth2 token following the workflow described at https://byuoit.atlassian.net/wiki/display/WSO2/OAuth+2.0#OAuth2.0-AuthorizationCode

You can get the person data using the following function (assuming you’ve already made the CAS run-around to get a temporary authorization code by visiting the URL you’ll get from (authkey-GET-url)

(defn api-user-data
  "Already having an auth code, obtain and decrypt the user data from a token request. Takes a map as: 
  {:client-id <STR>,
   :client-secret <STR>,
   :redirect-uri <STR>,
   :authorization-code <STR>}"
  [post-map]
  (let [post-response (stage2-request post-map)]
    (-> post-response
        :body
        json/decode
        (get "id_token") ;; the actual JWT
        get-jwt-body)))

Changes

  • Starting prep work with BYUs new oauth2 setup

Future Work

  • [ ] Allow service to be either a key (:schedule) or a string url for those service addresses that aren’t encoded in.
  • [ ] Get URL validation working
  • [ ] Expand URL list for more web services

License

Copyright © 2016 Office of Digital Humanities, BYU

Distributed under the Eclipse Public License version 1.0

Releases

No releases published

Packages

No packages published