Skip to content

feat: geoserver crud functionality, basic authorization #50

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

justiandevs
Copy link

@justiandevs justiandevs commented Apr 1, 2025

Summary by CodeRabbit

  • New Features
    • Added support for handling and validating WFS (Web Feature Service) Transaction requests, including detection and forwarding of XML transaction bodies.
    • Enhanced configuration options for CORS, including allowed origins, headers, and credentials.
  • Bug Fixes
    • Improved error handling for XML parsing and validation failures in transaction requests.
  • Chores
    • Updated backend and authorization service URLs in configuration for improved connectivity.
    • Minor variable renaming and whitespace adjustments for clarity.

Copy link
Member

@bartjkdp bartjkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this looks good, some small changes requested. I think we can do some refactoring after we merged this PR.

@justiandevs justiandevs requested a review from Copilot April 23, 2025 20:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds geoserver CRUD functionality with basic authorization, focusing on supporting WFS transactions.

  • Introduces new WFS transaction types and XML mappings (internal/wfs/transaction.go).
  • Adds a utility for extracting transaction metadata (internal/utils/utils.go).
  • Updates configuration settings and improves authorization logic for transaction requests (config.yaml, cmd/filter-proxy/main.go).

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/wfs/transaction.go Added new WFS transaction types and XML mapping
internal/utils/utils.go Added GetTransactionMetadata utility function
config.yaml Updated backend URL and CORS configuration
cmd/filter-proxy/main.go Enhanced request authorization and transaction handling
Comments suppressed due to low confidence (2)

cmd/filter-proxy/main.go:207

  • The 'bytes' package is used here but not imported; please add 'import "bytes"' to avoid build errors.
requestBody = bytes.NewReader(marshaledBody)

cmd/filter-proxy/main.go:431

  • [nitpick] Consider correcting 'laagnaam' to a more standardized term like 'layer name' to improve clarity in log messages.
log.Printf("%+v", "laagnaam"+layerName)

@justiandevs
Copy link
Author

@CodeRabbit

Copy link

coderabbitai bot commented Apr 24, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get PR information
gh pr view 50 --json title,body,filesChanged

# Get repository information
cat README.md 2>/dev/null || echo "README not found"

# List files changed in the PR
gh pr view 50 --json files -q '.files[].path'

Length of output: 1181


🏁 Script executed:

#!/bin/bash
# Get PR information with correct fields
gh pr view 50 --json title,body,changedFiles

# Get the content of files changed in the PR
echo "=== cmd/filter-proxy/main.go ==="
cat cmd/filter-proxy/main.go

echo "=== config.yaml ==="
cat config.yaml

echo "=== internal/utils/utils.go ==="
cat internal/utils/utils.go

echo "=== internal/wfs/transaction.go ==="
cat internal/wfs/transaction.go

# Get the diff to see the changes
echo "=== Diff ==="
gh pr view 50 --json files -q '.files[].patch'

Length of output: 26314


@justiandevs Hi there! I see you've mentioned me on PR #50 "feat: geoserver crud functionality, basic authorization". I'd be happy to help you with this PR that adds GeoServer CRUD functionality and basic authorization support.

I can:

  • Review the code changes and provide feedback
  • Help with testing scenarios
  • Answer questions about the implementation
  • Suggest improvements or optimizations
  • Look for potential bugs or edge cases
  • Run specific commands to gather more information

What would you like me to help with specifically?

@justiandevs
Copy link
Author

@coderabbitai

Copy link

coderabbitai bot commented Apr 24, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get more detailed PR information
gh pr view 50 --json title,body,commits,files,additions,deletions

# Get the diff of the changes for review
gh pr diff 50

# List directory structure to understand project organization
find . -type f -name "*.go" | sort

Length of output: 15489


@justiandevs I see you're working on PR #50 which adds GeoServer CRUD functionality and basic authorization. Looking at the changes, I notice you've implemented:

  • WFS Transaction support (Insert, Update, Delete operations)
  • XML parsing for transaction bodies
  • Enhanced authorization logic to handle transactions
  • Updated CORS configuration
  • Added transaction validation

I can help you with:

  1. Reviewing the implementation of the WFS Transaction handling
  2. Checking for edge cases in the XML parsing logic
  3. Testing scenarios for the authorization flow
  4. Suggesting improvements for error handling
  5. Running additional analyses on the code

Let me know what specific aspect of the PR you'd like me to focus on!

@justiandevs
Copy link
Author

@coderabbitai I want a full PR review

Copy link

coderabbitai bot commented Apr 24, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the PR description and files changed
echo "=== PR DETAILS ==="
gh pr view 50 --json title,body,files,additions,deletions

# Get full diff to see all code changes
echo "=== FULL DIFF ==="
gh pr diff 50

# Get the commit messages to understand PR evolution
echo "=== COMMIT MESSAGES ==="
gh pr view 50 --json commits --jq '.commits[].messageHeadline'

# Get the README to understand project context
echo "=== README CONTENT ==="
cat README.md || echo "README not found"

# List the files modified in this PR with stats
echo "=== MODIFIED FILES WITH STATS ==="
gh pr view 50 --json files --jq '.files[] | {path: .path, additions: .additions, deletions: .deletions}'

# Get content of key Go files in the PR for detailed review
echo "=== EXAMINING KEY FILES ==="
for file in $(gh pr view 50 --json files --jq '.files[].path' | grep '\.go$'); do
  echo "=== FILE: $file ==="
  cat "$file" || echo "File not found"
  echo ""
done

Length of output: 35935


🏁 Script executed:

#!/bin/bash
# Get information about the repository and project context
echo "=== PROJECT STRUCTURE ==="
find . -type d | sort

echo "=== IMPORT GRAPH FOR WFS PACKAGE ==="
grep -r "github.com/delta10/filter-proxy/internal/wfs" --include="*.go" .

echo "=== CHECK FOR POTENTIAL RACE CONDITIONS ==="
grep -r "transaction" --include="*.go" . | grep -i "concurrent\|sync\|mutex\|lock"

echo "=== CHECK FOR ERROR HANDLING PATTERNS ==="
grep -r "err :=" --include="*.go" cmd/filter-proxy/main.go | wc -l
grep -r "if err != nil" --include="*.go" cmd/filter-proxy/main.go | wc -l

echo "=== LOOKING FOR XML SECURITY MEASURES ==="
grep -r "xml.Unmarshal" --include="*.go" . --context=3

echo "=== EXAMINING KEY FUNCTIONS ==="
grep -n -A 3 -B 3 "func authorizeRequestWithService" cmd/filter-proxy/main.go
grep -n -A 3 -B 3 "func GetTransactionMetadata" internal/utils/utils.go

echo "=== LOOKING FOR TESTING ==="
find . -name "*_test.go"

Length of output: 3152


🏁 Script executed:

#!/bin/bash
# Examine the config structure and related code
echo "=== CONFIG STRUCTURE ==="
grep -r "type Config struct" --include="*.go" ./internal/config/

# Check for existing WFS-related code
echo "=== EXISTING WFS HANDLING ==="
grep -r "WFS" --include="*.go" . | grep -v "github.com/delta10/filter-proxy/internal/wfs"

# Look at routing and request handling
echo "=== ROUTING AND PATH HANDLING ==="
grep -r "type Path struct" --include="*.go" ./internal/config/

# Check if there are tests for similar features
echo "=== WMS RELATED CODE (FOR COMPARISON) ==="
find . -name "wms*.go"
cat $(find . -name "wms*.go") 2>/dev/null || echo "No WMS files found"

# Check for potential security issues in XML parsing
echo "=== POTENTIAL XML SECURITY CONCERNS ==="
grep -r "xml.Marshal" --include="*.go" . --context=3

# Examine error logging patterns
echo "=== ERROR LOGGING PATTERNS ==="
grep -r "log.Print" --include="*.go" cmd/filter-proxy/main.go | head -n 10

Length of output: 2279


🏁 Script executed:

#!/bin/bash
# Get the full Config struct definition to understand configuration
echo "=== CONFIG STRUCT DEFINITION ==="
cat ./internal/config/config.go

# Check how different requests are authorized
echo "=== AUTHORIZATION PATTERNS ==="
grep -n -A 20 -B 5 "if authorizationBody\[\"service\"\] ==" cmd/filter-proxy/main.go

# Look for input validation and security measures
echo "=== INPUT VALIDATION ==="
grep -r "return http.StatusBadRequest" --include="*.go" ./cmd/filter-proxy/main.go

# Examine how XML structures are defined for security
echo "=== XML STRUCT DEFINITIONS ==="
cat ./internal/wfs/transaction.go

# Check authorization service interaction
echo "=== AUTHORIZATION SERVICE URL HANDLING ==="
grep -r "AuthorizationServiceURL" --include="*.go" .

# Check for XML validation logic
echo "=== TRANSACTION VALIDATION LOGIC ==="
grep -n -A 10 -B 2 "transactionSet :=" --include="*.go" .

Length of output: 6108


@justiandevs Here's my full review of PR #50 "feat: geoserver crud functionality, basic authorization":

👍 Code Additions

  1. WFS Transaction Support

    • Well-structured XML models in internal/wfs/transaction.go
    • Proper handling of different transaction types (Insert, Update, Delete)
    • Good use of Go's XML marshaling/unmarshaling capabilities
  2. Security Measures

    • Only allowing one WFS transaction at a time prevents potential abuse
    • Validating transaction body before processing
    • Proper error handling for malformed requests
  3. Configuration Changes

    • CORS settings properly configured for local development
    • Added POST method to the allowed methods for /api/ows path

🛠️ Suggestions for Improvement

  1. Code Quality Issues

    • Debug logging statement log.Printf("%+v", "laagnaam"+layerName) should be removed or replaced with proper logging
    • The authorizeRequestWithService function is quite large (>100 lines) and could be split into smaller, focused functions
  2. Error Handling

    • Some error messages could be more descriptive for easier debugging
    • Consider using structured logging with error contexts
  3. XML Security

    • Consider adding XML size limits to prevent XML bomb attacks
    • XML namespace validation could be more explicit
  4. Documentation

    • The new GetTransactionMetadata function lacks documentation comments
    • WFS transaction validation logic would benefit from inline comments
  5. Testing

    • No unit tests were added for the new WFS transaction functionality
    • XML parsing and validation is complex and would benefit from test coverage

⚠️ Potential Issues

  1. Error in Transaction Counting Logic:

    if transactionCount > 1 {
        log.Printf("we only allow one wfs transaction at a time")
        return http.StatusBadRequest, nil, false
    }

    This only checks that there's at most one transaction type of each kind (Insert, Update, Delete), but doesn't verify that there's at most one transaction type in total.

  2. Combining Query Parameters & XML:

    if len(body) > 0 && len(queryParams) > 0 {
        log.Printf("Invalid: both XML and query param are set")
        return http.StatusBadRequest, nil, false
    }

    This check is good, but a more specific error message would help clients understand the issue.

🔄 Testing Considerations

  1. Manual Testing Scenarios:
    • Test Insert, Update, and Delete operations individually
    • Verify error handling for malformed XML
    • Test authorization failures for different transaction types
    • Test payload size limits

Would you like me to explore any specific aspect of the PR in more detail?

Copy link

coderabbitai bot commented May 12, 2025

Walkthrough

The changes introduce WFS (Web Feature Service) transaction detection and handling into the filter-proxy service. This includes parsing and validating XML transaction bodies, extracting metadata, updating the authorization flow, and modifying request forwarding logic. Supporting utilities and new XML struct definitions for WFS transactions are also added. Configuration updates enable CORS and adjust backend URLs.

Changes

File(s) Change Summary
cmd/filter-proxy/main.go Integrates WFS transaction detection and validation in authorization and proxying logic; updates function signatures, error handling, and request construction to handle XML transaction bodies; improves variable naming.
config.yaml Adds and activates CORS configuration, modifies backend URLs, allowed HTTP methods, and formatting.
internal/utils/utils.go Adds GetTransactionMetadata function to extract layer name and count from a WFS transaction.
internal/wfs/transaction.go Adds new XML-serializable structs for WFS Transaction, Insert, Update, Delete, and related elements.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Proxy
    participant AuthService
    participant Backend

    Client->>Proxy: HTTP Request (may include WFS Transaction XML)
    Proxy->>Proxy: Parse and preserve body
    Proxy->>Proxy: If not passthrough, check for WFS Transaction
    alt WFS Transaction detected
        Proxy->>Proxy: Unmarshal XML to Transaction struct
        Proxy->>Proxy: Extract metadata (layer name, count)
        Proxy->>AuthService: Authorize with transaction info
        AuthService-->>Proxy: Authorization response
        Proxy->>Backend: Forward request with validated XML body
    else Not a WFS Transaction
        Proxy->>AuthService: Authorize with standard info
        AuthService-->>Proxy: Authorization response
        Proxy->>Backend: Forward request as-is
    end
    Backend-->>Proxy: Backend response
    Proxy-->>Client: Return response
Loading

Poem

In the warren of code, a new path appears,
WFS transactions now handled with cheers!
XMLs parsed, layer names found,
Through proxy and auth, requests circle around.
With CORS now enabled, and config refined,
This bunny’s quite proud of the features combined!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b014e6 and 6f6cbb3.

📒 Files selected for processing (1)
  • cmd/filter-proxy/main.go (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/filter-proxy/main.go (3)
internal/wfs/transaction.go (1)
  • Transaction (5-14)
internal/config/config.go (3)
  • Config (48-59)
  • Backend (9-25)
  • Path (27-37)
internal/utils/utils.go (3)
  • QueryParamsContainMultipleKeys (25-38)
  • QueryParamsToLower (14-23)
  • GetTransactionMetadata (108-125)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (6)
cmd/filter-proxy/main.go (6)

8-8: LGTM! Necessary imports for WFS transaction support.

The addition of encoding/xml and the internal wfs package import are required for the new WFS transaction functionality.

Also applies to: 25-25


134-134: LGTM! Well-designed function signature enhancement.

The addition of the body parameter and isTransaction return value properly enables WFS transaction detection and handling in the authorization flow.


372-376: LGTM! Consistent function signature and return value handling.

The function signature properly accepts the body parameter and all return statements correctly include the isTransaction boolean.


412-418: LGTM! Correct service type determination logic.

The conditional logic properly sets the service to "WFS" for detected transactions and falls back to the query parameter value for non-transaction requests.


514-514: LGTM! Good variable naming improvement.

Renaming the variable to resBody improves clarity by distinguishing it from the request body parameter.


375-375: LGTM! Consistent return statement updates throughout the function.

All return statements have been properly updated to include the isTransactionSet boolean, maintaining consistency with the new function signature.

Also applies to: 380-380, 400-400, 433-433, 448-448, 477-477, 483-483, 489-489, 509-509, 517-517, 524-524, 531-531

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (7)
config.yaml (4)

7-7: Avoid hard-coding a trailing slash in authorizationServiceUrl

Several places in the code join the base URL with additional path fragments; having a hard-coded trailing slash can lead to duplicated “//” or broken URLs when path.Join is used elsewhere. Consider removing the slash and let the client code normalise the path.

-authorizationServiceUrl: http://localhost:8000/atlas/api/v1/authorize/
+authorizationServiceUrl: http://localhost:8000/atlas/api/v1/authorize

16-25: YAML indentation does not follow the 2-space rule

yamllint is already warning that the list items are indented with 4 spaces instead of 2.
While it does not break runtime behaviour, it pollutes CI pipelines that lint the repository.

-  allowedOrigins:
-  - http://localhost:8000
+  allowedOrigins:
+    - http://localhost:8000

Apply the same fix to allowedHeaders, allowedMethods, etc.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 19-19: wrong indentation: expected 2 but found 4

(indentation)


32-34: Restrict POST to the subset of operations you actually support

The proxy currently allows any POST on /api/ows. The back-end only handles POST for <Transaction> requests; everything else is a GET.
Attackers could combine this with XML/JSON payloads you do not expect.

If feasible, add a validator in the request handler (or here, add separate path entries) to explicitly reject non-transaction POSTs.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 33-33: wrong indentation: expected 4 but found 6

(indentation)


169-169: Missing newline at end of file

A final newline avoids false-diffs in subsequent commits and is a POSIX convention.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 169-169: no new line character at the end of file

(new-line-at-end-of-file)

internal/wfs/transaction.go (1)

26-33: Filter only supports one <FeatureId> – consider slice for completeness

Real-world transactions often specify multiple feature IDs. Modelling this as a slice keeps the parser future-proof:

-type Filter struct {
-	FeatureID FeatureID `xml:"FeatureId"`
-}
+type Filter struct {
+	FeatureID []FeatureID `xml:"FeatureId"`
+}
cmd/filter-proxy/main.go (2)

431-434: Remove temporary debug logging

log.Printf("%+v", "laagnaam"+layerName) leaks internal details and clutters logs.
Either switch to structured logging or delete.

-				log.Printf("%+v", "laagnaam"+layerName)

398-402: Clarify error for simultaneous body & query parameters

Invalid: both XML and query param are set gives little context.
Include the offending parameter names to aid client debugging and return a RFC-consistent 400 message.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 979e420 and 0424fa4.

📒 Files selected for processing (4)
  • cmd/filter-proxy/main.go (9 hunks)
  • config.yaml (3 hunks)
  • internal/utils/utils.go (2 hunks)
  • internal/wfs/transaction.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/utils/utils.go (1)
internal/wfs/transaction.go (1)
  • Transaction (5-14)
🪛 YAMLlint (1.35.1)
config.yaml

[warning] 19-19: wrong indentation: expected 2 but found 4

(indentation)


[warning] 28-28: wrong indentation: expected 0 but found 2

(indentation)


[warning] 33-33: wrong indentation: expected 4 but found 6

(indentation)


[error] 169-169: no new line character at the end of file

(new-line-at-end-of-file)

🪛 golangci-lint (1.64.8)
internal/wfs/transaction.go

9-9: SA5008: invalid XML tag: unknown option "xmlns:xsi"

(staticcheck)


10-10: SA5008: invalid XML tag: unknown option "xsi:schemaLocation"

(staticcheck)

🔇 Additional comments (1)
config.yaml (1)

146-149: Check that both GeoServer back-end URLs are kept in sync

geoserver now points at http://localhost:8080/geoserver, but geoserver-wmts still points to http://localhost/geoserver.
If WMTS also moved to port 8080 this will 404 silently.

Please verify the intended port.

Comment on lines +9 to +10
XSI string `xml:",xmlns:xsi,attr"`
SchemaLocation string `xml:",xsi:schemaLocation,attr"`
Copy link

@coderabbitai coderabbitai bot May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Invalid encoding/xml struct tags – will break (un)marshalling

xml:",xmlns:xsi,attr" and xml:",xsi:schemaLocation,attr" are not valid tag syntaxes and are flagged by staticcheck.
Use the attribute name directly before ,attr.

-	XSI            string         `xml:",xmlns:xsi,attr"`
-	SchemaLocation string         `xml:",xsi:schemaLocation,attr"`
+	XSI            string         `xml:"xmlns:xsi,attr"`
+	SchemaLocation string         `xml:"xsi:schemaLocation,attr"`

Without this fix the proxy will silently drop those attributes on marshal and error on unmarshal if validation is strict.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
XSI string `xml:",xmlns:xsi,attr"`
SchemaLocation string `xml:",xsi:schemaLocation,attr"`
XSI string `xml:"xmlns:xsi,attr"`
SchemaLocation string `xml:"xsi:schemaLocation,attr"`
🧰 Tools
🪛 golangci-lint (1.64.8)

9-9: SA5008: invalid XML tag: unknown option "xmlns:xsi"

(staticcheck)


10-10: SA5008: invalid XML tag: unknown option "xsi:schemaLocation"

(staticcheck)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justiandevs ik twijfel hier nog over. Is dit niet nodig?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Als ik hier een , voor weghaal dan breekt alle functionaliteit en gaat het niet goed met het vormgeven van de request vanuit FilterProxy naar GeoServer.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
cmd/filter-proxy/main.go (1)

372-532: 🛠️ Refactor suggestion

Function is too large and complex - needs refactoring

This function has grown to 160+ lines and handles multiple responsibilities. As noted in previous reviews, it would benefit from being split into smaller, focused functions.

Consider breaking it down like this:

func authorizeRequestWithService(config *config.Config, backend config.Backend, path config.Path, r *http.Request, filterParams map[string]interface{}, body []byte) (int, *AuthorizationResponse, bool) {
    // Validate request structure
    if err := validateRequest(r, body); err != nil {
        return http.StatusBadRequest, nil, false
    }
    
    // Build authorization payload based on service type
    authBody, isTransaction, err := buildAuthorizationBody(backend, path, r, body)
    if err != nil {
        return http.StatusBadRequest, nil, false
    }
    
    // Perform authorization request
    return performAuthorization(config, r, authBody, isTransaction)
}

func validateRequest(r *http.Request, body []byte) error { /* ... */ }
func buildAuthorizationBody(backend config.Backend, path config.Path, r *http.Request, body []byte) (map[string]interface{}, bool, error) { /* ... */ }
func performAuthorization(config *config.Config, r *http.Request, authBody map[string]interface{}, isTransaction bool) (int, *AuthorizationResponse, bool) { /* ... */ }
♻️ Duplicate comments (1)
cmd/filter-proxy/main.go (1)

98-99: ⚠️ Potential issue

Request body consumption still not addressed

This issue was previously identified but remains unfixed. Reading the request body without restoring it causes downstream handlers to see EOF when they try to read the body.

The previous suggestion to restore the body should be implemented:

 body, _ := io.ReadAll(r.Body)
+r.Body.Close()
+r.Body = io.NopCloser(bytes.NewReader(body))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0424fa4 and 0b014e6.

📒 Files selected for processing (1)
  • cmd/filter-proxy/main.go (9 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/filter-proxy/main.go (3)
internal/wfs/transaction.go (1)
  • Transaction (5-14)
internal/config/config.go (3)
  • Config (48-59)
  • Backend (9-25)
  • Path (27-37)
internal/utils/utils.go (3)
  • QueryParamsContainMultipleKeys (25-38)
  • QueryParamsToLower (14-23)
  • GetTransactionMetadata (108-125)
🔇 Additional comments (1)
cmd/filter-proxy/main.go (1)

134-134: Function signature enhancement looks good

The addition of the isTransaction boolean return value is well-integrated and necessary for the new WFS transaction handling logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants