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

Upgrade deps #17

Merged
merged 6 commits into from
Dec 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,28 @@ on:
branches: [ master ]

jobs:
test-using-java-11:
name: 'Test using Java 11'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 11

- name: Print java version
run: java -version
test-clojure:

- name: Install dependencies
run: lein deps
strategy:
matrix:
java-version: [11, 17, 21]

- name: Run clj tests
run: lein test

lint:
name: 'Lint'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java-version }}

- uses: actions/setup-java@v1
with:
java-version: 11
- name: Print java version
run: java -version

- name: Lint check
run: lein lint
- name: Install dependencies
run: lein deps

- name: Run clj tests
run: lein test
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ jobs:
test-clojure:
strategy:
matrix:
java-version: [8, 11]
java-version: [11, 17, 21]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java-version }}

- name: Print java version
Expand All @@ -34,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test-clojure]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.2.2

- name: Install dependencies
run: lein deps
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.3.0] — 2024-12-06
### Changed
* Upgrade dependencies
* cheshire from 5.11.0 to 5.13.0
* clj-http from 3.12.3 to 3.13.0
* org.clojure/core.cache from 1.0.225 to 1.1.234
* com.auth0/java-jwt from 4.0.0 to 4.4.0
* org.bouncycastle/* from 1.78.1 to 1.79
* Remove some dependencies
* ring/ring-codec
* org.bovinegenius/exploding-fish

## [0.2.2] — 2024-08-07
### Changed
* Bump dependencies
Expand Down
26 changes: 12 additions & 14 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject nubank/clj-github-app "0.2.2"
(defproject nubank/clj-github-app "0.3.0"
:description "A library to implement GitHub Apps in Clojure."
:url "http://github.com/nubank/clj-github-app"
:license {:name "Eclipse Public License"
Expand All @@ -7,23 +7,21 @@
:username :env/clojars_username
:password :env/clojars_passwd
:sign-releases false}]]
:dependencies [[cheshire/cheshire "5.11.0"]
[clj-http/clj-http "3.12.3"]
[org.clojure/core.cache "1.0.225"]
[com.auth0/java-jwt "4.0.0"]
[org.bouncycastle/bcpkix-jdk18on "1.78.1"]
[org.bouncycastle/bcpg-jdk18on "1.78.1"]
:dependencies [[cheshire/cheshire "5.13.0"]
[clj-http/clj-http "3.13.0"]
[org.clojure/core.cache "1.1.234"]
[com.auth0/java-jwt "4.4.0"]
[org.bouncycastle/bcpkix-jdk18on "1.79"]
[org.bouncycastle/bcprov-jdk18on "1.79"]
[pandect/pandect "1.0.2"]
[ring/ring-codec "1.2.0"]
[crypto-equality/crypto-equality "1.0.1"]
[org.bovinegenius/exploding-fish "0.3.6"]]
:plugins [[lein-ancient "0.6.15"]
[crypto-equality/crypto-equality "1.0.1"]]
:plugins [[lein-ancient "0.7.0"]
[lein-changelog "0.3.2"]
[lein-cljfmt "0.6.4" :exclusions [org.clojure/clojure]]
[lein-cloverage "1.0.13"]
[lein-cljfmt "0.9.2" :exclusions [org.clojure/clojure]]
[lein-cloverage "1.2.4"]
[lein-nsorg "0.3.0" :exclusions [org.clojure/clojure]]
[lein-shell "0.5.0"]]
:profiles {:dev {:dependencies [[org.clojure/clojure "1.10.3"]]}}
:profiles {:dev {:dependencies [[org.clojure/clojure "1.12.0"]]}}
:deploy-repositories [["releases" :clojars]]
:aliases {"update-readme-version" ["shell" "sed" "-i" "s|\\\\[nubank/clj-github-app \"[0-9.]*\"\\\\]|[nubank/clj-github-app \"${:version}\"]|" "README.md"]
"lint" ["do" ["cljfmt" "check"] ["nsorg"]]
Expand Down
15 changes: 8 additions & 7 deletions src/clj_github_app/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(:require [clj-github-app.token-manager :as token-manager]
[clj-http.client :as http]
[clj-http.conn-mgr :as conn-mgr]
[clojure.string :as str]
[org.bovinegenius.exploding-fish :as uri])
(:import (java.lang AutoCloseable)))
[clojure.string :as str])
(:import (java.lang AutoCloseable)
(java.net URI)))

(defprotocol AppClient
(app-request* [_ opts])
Expand All @@ -25,10 +25,11 @@
(subs trimmed-url-or-path 1)
trimmed-url-or-path)))

(defn resolve-url [path-or-url github-api-url]
(->> path-or-url
remove-leading-slash
(uri/resolve-uri (str github-api-url "/"))))
(defn resolve-url [path-or-url ^String github-api-url]
(-> (URI/create (str github-api-url "/"))
(.resolve ^String (remove-leading-slash path-or-url))
.normalize
.toString))

(defrecord AppClientImpl [github-api-url token-manager connection-pool]
AppClient
Expand Down
18 changes: 14 additions & 4 deletions src/clj_github_app/token_manager.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(ns clj-github-app.token-manager
(:require [clj-http.client :as http]
[clojure.core.cache :as cache]
[org.bovinegenius.exploding-fish :as uri]
[ring.util.codec :as codec])
[clojure.core.cache :as cache])
(:import (clojure.core.cache CacheProtocol)
(com.auth0.jwt JWT)
(com.auth0.jwt.algorithms Algorithm)
(java.io StringReader)
(java.net URI URLEncoder)
(java.nio.charset StandardCharsets)
(java.security KeyFactory)
(java.security.spec PKCS8EncodedKeySpec)
(java.text SimpleDateFormat)
Expand Down Expand Up @@ -83,6 +83,16 @@
(:token (cache/lookup (swap! cache cache/through-cache installation-id get-installation-token-fn)
installation-id))))

(defn- url-encode [^String s]
(URLEncoder/encode s StandardCharsets/UTF_8))

(defn- installation-token-uri
[github-api-url installation-id]
(-> (URI/create (str github-api-url "/"))
(.resolve (str "app/installations/" (url-encode (str installation-id)) "/access_tokens"))
.normalize
.toString))

(defn make-token-manager [github-api-url github-app-id private-key-pem-str]
(let [signing-algorithm (make-signing-algorithm private-key-pem-str)
cache (atom (GithubAppTokenCache. {}))]
Expand All @@ -91,7 +101,7 @@
(fn []
(make-app-token signing-algorithm github-app-id))
(fn [installation-id]
(let [url (uri/resolve-uri (str github-api-url "/") (str "app/installations/" (codec/url-encode (str installation-id)) "/access_tokens"))]
(let [url (installation-token-uri github-api-url installation-id)]
(:body (http/post url
{:oauth-token (make-app-token signing-algorithm github-app-id)
:as :json
Expand Down
Loading