Skip to content

Commit

Permalink
Workaround jwt filter ignoring urlPattern, add graphql associations #907
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Feb 1, 2024
1 parent fc96bbe commit 7d64314
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.apache.http.HttpStatus
class GraphqlInterceptor {

GraphqlInterceptor() {
match uri: '/ws/graphql/**' // Web services - uses the supplied JWT bearer token to authorize
//match uri: '/ws/graphql/**' // Web services - uses the supplied JWT bearer token to authorize.
// WS endpoints now use the GraphSQLWsController which decodes the JWT then forwards on.

match uri: '/graphql/**' // Admin UI - uses the jee session state to authorize
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package au.org.ala.ecodata

@au.ala.org.ws.security.RequireApiKey(scopes=["profile", "email", "openid"])
/**
* This class exists to allow the RequireApiKey annotation to be applied to the path around the GraphQL endpoint
* so we can decode the JWT before forwarding the request on.
*/
class GraphqlWsController {
def index() {
forward(uri:'/graphql/index')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class UrlMappings {
}

"/ws/graphql" {
controller = 'graphql'
controller = 'graphqlWs'
}

"/ws/paratoo/user-projects" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package au.org.ala.ecodata.graphql.mappers

import au.org.ala.ecodata.Activity
import au.org.ala.ecodata.Document
import au.org.ala.ecodata.Organisation
import au.org.ala.ecodata.Program
import au.org.ala.ecodata.Project
import au.org.ala.ecodata.ProjectActivity
import au.org.ala.ecodata.Report
Expand Down Expand Up @@ -78,6 +80,18 @@ class ProjectGraphQLMapper {
}
}

add('program', [Program]) {
dataFetcher { Program program ->
Program.findByProgramIdAndStatusNotEqual(project.programId, Status.DELETED)
}
}

add('organisation', [Organisation]) {
dataFetcher { Organisation organisation ->
Organisation.findByOrganisationIdAndStatusNotEqual(project.organisationId, Status.DELETED)
}
}

add('sites', [Site]) {
dataFetcher { Project project ->
Site.findAllByProjectsAndStatusNotEqual(project.projectId, Status.DELETED)
Expand Down

0 comments on commit 7d64314

Please sign in to comment.