-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add authentication to google assistant / slack (#14)
- Loading branch information
Guillaume Naimi
committed
Dec 16, 2019
1 parent
7da42db
commit b137ce4
Showing
10 changed files
with
171 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/io/saagie/astonparking/exceptions/PickException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.saagie.astonparking.exceptions | ||
|
||
import java.lang.IllegalArgumentException | ||
import java.time.LocalDate | ||
|
||
sealed class PickException(message: String): IllegalArgumentException(message) { | ||
data class NoScheduleError(private val date: LocalDate) : PickException("No schedule for the date $date") | ||
data class NoFreeSpotsError(private val date: LocalDate) : PickException("No free spot for the date $date") | ||
object AlreadyPickError : PickException("A spot is already reserved for you") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/io/saagie/astonparking/googleActions/TokenDecoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.saagie.astonparking.googleActions | ||
|
||
|
||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken | ||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier | ||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport | ||
import com.google.api.client.json.jackson2.JacksonFactory | ||
import java.io.IOException | ||
import java.security.GeneralSecurityException | ||
|
||
class TokenDecoder(private val clientId: String) { | ||
|
||
@Throws(GeneralSecurityException::class, IOException::class) | ||
fun decodeIdToken(idTokenString: String): GoogleIdToken.Payload { | ||
val transport = GoogleNetHttpTransport.newTrustedTransport() | ||
val jsonFactory = JacksonFactory.getDefaultInstance() | ||
|
||
val verifier = GoogleIdTokenVerifier.Builder(transport, jsonFactory) | ||
// Specify the CLIENT_ID of the app that accesses the backend: | ||
.setAudience(listOf(clientId)) | ||
.build() | ||
|
||
val idToken = verifier.verify(idTokenString) | ||
return idToken.payload | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters