Skip to content

Commit

Permalink
chore: update to new Gropius OAuth2 flow
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasmueller committed Dec 3, 2024
1 parent dde3d8f commit f0971a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ data class ExportConfig(
data class Authentication(
@ConfigAlias("authentication-url")
val authenticationUrl: URL,
@ConfigAlias("username")
val userName: Masked,
val password: Masked,
@ConfigAlias("client-id")
val clientId: Masked,
@ConfigAlias("client-secret")
val clientSecret: Masked,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ class ExporterManager(exportConfig: ExportConfig) {
graphQLBackendUrl = gropiusConfig.graphQLBackendUrl,
graphQLBackendAuthentication = GropiusExporter.Config.Authentication(
authenticationUrl = gropiusConfig.graphQLBackendAuthentication.authenticationUrl,
userName = gropiusConfig.graphQLBackendAuthentication.userName.value,
password = gropiusConfig.graphQLBackendAuthentication.password.value,
clientId = gropiusConfig.graphQLBackendAuthentication.clientId.value,
clientSecret = gropiusConfig.graphQLBackendAuthentication.clientSecret.value,
),
gropiusComponentHandling = when(gropiusConfig.gropiusComponentHandling) {
ExportConfig.Exporters.Gropius.ComponentHandling.Modify -> GropiusExporter.Config.ComponentHandling.Modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class GropiusExporter(private val config: Config) : Exporter {

data class Authentication(
val authenticationUrl: URL,
val userName: String,
val password: String,
val clientId: String,
val clientSecret: String,
)
}

Expand All @@ -46,9 +45,8 @@ class GropiusExporter(private val config: Config) : Exporter {
private val graphQLClient: GraphQLClient = GropiusGraphQLClient(
backendUrl = config.graphQLBackendUrl,
authenticationUrl = config.graphQLBackendAuthentication.authenticationUrl,
userName = config.graphQLBackendAuthentication.userName,
password = config.graphQLBackendAuthentication.password,
clientId = config.graphQLBackendAuthentication.clientId,
clientSecret = config.graphQLBackendAuthentication.clientSecret,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import kotlin.time.toKotlinDuration
class GropiusGraphQLClient(
private val backendUrl: URL,
private val authenticationUrl: URL,
private val userName: String,
private val password: String,
private val clientId: String,
private val clientSecret: String,
) : GraphQLClient {

private val log = KotlinLogging.logger {}
Expand All @@ -46,10 +45,9 @@ class GropiusGraphQLClient(

private fun getAuthenticationToken(): Either<GraphQLClient.RequestError, Token> {
val requestData = mapOf(
"grant_type" to "password",
"grant_type" to "client_credentials",
"client_id" to clientId,
"password" to password,
"username" to userName
"client_secret" to clientSecret,
)

val requestBody = requestData
Expand Down
9 changes: 4 additions & 5 deletions clara-app/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ export:
output-type: SVG
output-file: generated/architecture.svg
gropius:
project-id: d9cc0540-bb2d-4910-b30d-393ae18b84c1
graphql-backend-url: http://devonport.informatik.uni-stuttgart.de:8082/graphql
project-id: 3a9b8ed9-19e4-4346-9cc9-ce5ea092cc66
graphql-backend-url: http://localhost:8080/graphql
graphql-backend-authentication:
authentication-url: http://devonport.informatik.uni-stuttgart.de:3000/authenticate/oauth/5590d02a-99b5-4864-be49-e45f426332ab/token
username: ${CLARA_GROPIUS_GRAPHQL_USERNAME}
password: ${CLARA_GROPIUS_GRAPHQL_PASSWORD}
authentication-url: http://localhost:3000/auth/oauth/token
client-id: ${CLARA_GROPIUS_GRAPHQL_CLIENT_ID}
client-secret: ${CLARA_GROPIUS_GRAPHQL_CLIENT_SECRET}
component-handling: Delete
export-libraries: false

0 comments on commit f0971a7

Please sign in to comment.