Skip to content

Commit

Permalink
Blank OAuth2 setup
Browse files Browse the repository at this point in the history
  • Loading branch information
skuro committed Nov 6, 2012
0 parents commit 0fa42c9
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# clojure-app

FIXME

## Prerequisites

You will need [Leiningen][1] 1.7.0 or above installed.

[1]: https://github.com/technomancy/leiningen

## Running

To start a web server for the application, run:

lein ring server

## License

Copyright © 2012 FIXME
11 changes: 11 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(defproject clojure-app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.4.0"]
[compojure "1.1.1"]
[tk.skuro/clj-oauth2 "0.5.1"]
[ring/ring-jetty-adapter "1.1.0"]]
:plugins [[lein-ring "0.7.3"]]
:ring {:handler devcon.handler/app}
:profiles
{:dev {:dependencies [[ring-mock "0.1.3"]]}})
17 changes: 17 additions & 0 deletions resources/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Basic configuration properties
#Use the values from your account on the Alfresco Developer Portal (developer.alfresco.com)
#
#Set client_id to the value of "Api Key" (on the "Auth" tab when you edit an application in the portal)
#Set client_secret to the value of "Key Secret" (on the "Auth" tab when you edit an application in the portal)
#For this application, the redirect_uri should be set to "http://localhost:8090/alfapi/dance/callback"
#(The redirect_uri MUST match the value you set as the "Callback URL" on the "Auth" tab in the portal)

client-id="l7xx3f7c3c67d974472bb03850aaf6523eeb"
client-secret="d1e308dfc0ac4c7398c443436ea307be"
#redirect-uri=http://localhost:8090/alfapi/dance/callback
authorization-uri="https://api.alfresco.com/auth/oauth/versions/2/authorize?"
redirect-uri="http://localhost:3000/callback"
access-token-uri="https://api.alfresco.com/auth/oauth/versions/2/token"
#authURL=https://api.alfresco.com/auth/oauth/versions/2/authorize
#tokenURL=https://api.alfresco.com/auth/oauth/versions/2/token
#scope=public_api
20 changes: 20 additions & 0 deletions src/devcon.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(ns devcon
(:require [clojure.java.io :as io]
[clj-oauth2.ring :as oauth2-ring]))

(def file-name "config.properties")

(defn load-config
[]
(with-open [^java.io.Reader reader (-> file-name io/resource io/reader)]
(let [props (java.util.Properties.)]
(.load props reader)
(into {:scope ["public_api"]
:grant-type "authorization_code"
:get-state oauth2-ring/get-state-from-session
:put-state oauth2-ring/put-state-in-session
:get-target oauth2-ring/get-target-from-session
:put-target oauth2-ring/put-target-in-session
:get-oauth2-data oauth2-ring/get-oauth2-data-from-session
:put-oauth2-data oauth2-ring/put-oauth2-data-in-session}
(for [[k v] props] [(keyword k) (read-string v)])))))
17 changes: 17 additions & 0 deletions src/devcon/handler.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns devcon.handler
(:use compojure.core)
(:require [devcon]
[devcon.start :as start]
[compojure.handler :as handler]
[clj-oauth2.ring :as o2-ring]
[clj-oauth2.client :as o2]))

(defroutes app-routes
(GET "/" [] start/start))

(def config (devcon/load-config))

(def app
(-> app-routes
(o2-ring/wrap-oauth2 config)
handler/site))
4 changes: 4 additions & 0 deletions src/devcon/jetty.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(ns devcon.jetty
(:require [compojure.route :as route]
[ring.adapter.jetty :as jetty]))

7 changes: 7 additions & 0 deletions src/devcon/start.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns devcon.start
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]))

(defn start [_]
"Hello, world!")

0 comments on commit 0fa42c9

Please sign in to comment.