Skip to content

Commit

Permalink
Remove accessToken from authentication (#111)
Browse files Browse the repository at this point in the history
* Update to Java 21

* Update sbt to 1.10.3 (#108)

* Update sbt to 1.10.4 (#109)

* Update sbt to 1.10.5 (#110)

* Remove accessToken from authentication

* Fixes getUser call

* Removes accessToken from HomeController as well

---------

Co-authored-by: Willem Jan Glerum <[email protected]>
Co-authored-by: lunatech-scala-steward[bot] <166295259+lunatech-scala-steward[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent e38850f commit 96fa89b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sbt test
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sbt test
3 changes: 1 addition & 2 deletions app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class HomeController @Inject()(
cache: SyncCacheApi
) extends AbstractController(cc) {

private val accessToken = configuration.get[String]("accessToken")
private val organization = configuration.get[String]("githubOrganisation")
private val repository = configuration.get[String]("githubRepository")
private val branch = configuration.get[String]("githubBranch")
Expand Down Expand Up @@ -123,7 +122,7 @@ class HomeController @Inject()(
} else {
cache.get(post.authorName) match {
case None =>
val getUser = Github(Option(accessToken)).users.get(post.authorName).execFuture[HttpResponse[String]]()
val getUser = Github().users.get(post.authorName).execFuture[HttpResponse[String]]()
getUser.map {
case Left(_) => Ok(views.html.post(post))
case Right(re) =>
Expand Down
5 changes: 2 additions & 3 deletions app/modules/ApplicationStart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ class ApplicationStart @Inject()(
cache: SyncCacheApi
) {

private val accessToken = configuration.get[String]("accessToken")
private val organization = configuration.get[String]("githubOrganisation")
private val repository = configuration.get[String]("githubRepository")
private val branch = configuration.get[String]("githubBranch")

private def getContents = Github(Option(accessToken)).repos.getContents(organization, repository, "posts", Option(branch)).execFuture[HttpResponse[String]]()
private def getContents = Github().repos.getContents(organization, repository, "posts", Option(branch)).execFuture[HttpResponse[String]]()

{
// Parse all and put into cache
Expand Down Expand Up @@ -108,7 +107,7 @@ class ApplicationStart @Inject()(
val authorName = post.authorName
cache.get(authorName) match {
case None =>
val getUser = Github(Option(accessToken)).users.get(authorName).execFuture[HttpResponse[String]]()
val getUser = Github().users.get(authorName).execFuture[HttpResponse[String]]()
val postWithAuthor = getUser.map {
case Left(_) => p
case Right(rUser) =>
Expand Down
1 change: 0 additions & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# https://www.playframework.com/documentation/latest/Configuration

# Github configuration
accessToken = ${?access_token}
githubOrganisation = lunatech-labs
githubOrganisation = ${?github_organisation}
githubRepository = lunatech-blog
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.2
sbt.version=1.10.5

0 comments on commit 96fa89b

Please sign in to comment.