|
| 1 | +# JIRA Proxy API Documentation |
| 2 | + |
| 3 | +The JIRA Proxy Controller provides a secure interface to interact with JIRA instances through the Sentrius platform. It mirrors key JIRA REST API endpoints while maintaining the platform's authentication and authorization mechanisms. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The JIRA proxy is implemented in the `llm-proxy` module and provides authenticated access to JIRA functionality for agents and compliance tools. It follows the same security patterns as the existing OpenAI proxy. |
| 8 | + |
| 9 | +## Authentication |
| 10 | + |
| 11 | +All endpoints require: |
| 12 | +- Valid JWT token in the `Authorization` header (format: `Bearer <token>`) |
| 13 | +- User must have `CAN_LOG_IN` application access |
| 14 | +- At least one JIRA integration must be configured in the system |
| 15 | + |
| 16 | +## Endpoints |
| 17 | + |
| 18 | +### 1. Search Issues |
| 19 | + |
| 20 | +**GET** `/api/v1/jira/rest/api/3/search` |
| 21 | + |
| 22 | +Search for JIRA issues using JQL or simple text queries. |
| 23 | + |
| 24 | +**Parameters:** |
| 25 | +- `jql` (optional): JIRA Query Language string |
| 26 | +- `query` (optional): Simple text search query |
| 27 | + |
| 28 | +**Example:** |
| 29 | +```bash |
| 30 | +curl -X GET \ |
| 31 | + "https://your-instance/api/v1/jira/rest/api/3/search?query=bug" \ |
| 32 | + -H "Authorization: Bearer <jwt-token>" |
| 33 | +``` |
| 34 | + |
| 35 | +**Response:** Array of TicketDTO objects containing issue information. |
| 36 | + |
| 37 | +### 2. Get Issue |
| 38 | + |
| 39 | +**GET** `/api/v1/jira/rest/api/3/issue/{issueKey}` |
| 40 | + |
| 41 | +Retrieve information about a specific JIRA issue. |
| 42 | + |
| 43 | +**Parameters:** |
| 44 | +- `issueKey` (path): JIRA issue key (e.g., "PROJECT-123") |
| 45 | + |
| 46 | +**Example:** |
| 47 | +```bash |
| 48 | +curl -X GET \ |
| 49 | + "https://your-instance/api/v1/jira/rest/api/3/issue/PROJECT-123" \ |
| 50 | + -H "Authorization: Bearer <jwt-token>" |
| 51 | +``` |
| 52 | + |
| 53 | +**Response:** Issue status information. |
| 54 | + |
| 55 | +### 3. Add Comment |
| 56 | + |
| 57 | +**POST** `/api/v1/jira/rest/api/3/issue/{issueKey}/comment` |
| 58 | + |
| 59 | +Add a comment to a JIRA issue. |
| 60 | + |
| 61 | +**Parameters:** |
| 62 | +- `issueKey` (path): JIRA issue key |
| 63 | +- Request body: Comment object with `text` or `body` field |
| 64 | + |
| 65 | +**Example:** |
| 66 | +```bash |
| 67 | +curl -X POST \ |
| 68 | + "https://your-instance/api/v1/jira/rest/api/3/issue/PROJECT-123/comment" \ |
| 69 | + -H "Authorization: Bearer <jwt-token>" \ |
| 70 | + -H "Content-Type: application/json" \ |
| 71 | + -d '{"text": "This is a comment from the compliance agent"}' |
| 72 | +``` |
| 73 | + |
| 74 | +**Response:** Success/failure message. |
| 75 | + |
| 76 | +### 4. Assign Issue |
| 77 | + |
| 78 | +**PUT** `/api/v1/jira/rest/api/3/issue/{issueKey}/assignee` |
| 79 | + |
| 80 | +Assign a JIRA issue to a user. |
| 81 | + |
| 82 | +**Parameters:** |
| 83 | +- `issueKey` (path): JIRA issue key |
| 84 | +- Request body: Assignee object with `accountId` field |
| 85 | + |
| 86 | +**Example:** |
| 87 | +```bash |
| 88 | +curl -X PUT \ |
| 89 | + "https://your-instance/api/v1/jira/rest/api/3/issue/PROJECT-123/assignee" \ |
| 90 | + -H "Authorization: Bearer <jwt-token>" \ |
| 91 | + -H "Content-Type: application/json" \ |
| 92 | + -d '{"accountId": "user-account-id"}' |
| 93 | +``` |
| 94 | + |
| 95 | +**Response:** HTTP 204 (No Content) on success. |
| 96 | + |
| 97 | +## Configuration |
| 98 | + |
| 99 | +### JIRA Integration Setup |
| 100 | + |
| 101 | +Before using the proxy, ensure a JIRA integration is configured: |
| 102 | + |
| 103 | +1. Use the existing `/api/v1/integrations/jira/add` endpoint to add JIRA integration |
| 104 | +2. Provide required fields: `baseUrl`, `username`, `apiToken` |
| 105 | + |
| 106 | +### Security Model |
| 107 | + |
| 108 | +The proxy uses the existing security infrastructure: |
| 109 | +- JWT validation through Keycloak |
| 110 | +- User authentication via `BaseController.getOperatingUser()` |
| 111 | +- Access control through `@LimitAccess` annotations |
| 112 | +- OpenTelemetry tracing for monitoring |
| 113 | + |
| 114 | +## Implementation Details |
| 115 | + |
| 116 | +### Error Handling |
| 117 | + |
| 118 | +- **401 Unauthorized**: Invalid or missing JWT token |
| 119 | +- **404 Not Found**: No JIRA integration configured |
| 120 | +- **400 Bad Request**: Missing required parameters |
| 121 | +- **500 Internal Server Error**: JIRA operation failed |
| 122 | + |
| 123 | +### Integration Token Selection |
| 124 | + |
| 125 | +Currently, the proxy uses the first available JIRA integration found for the connection type "jira". In production environments, you may want to extend this to allow users to specify which integration to use. |
| 126 | + |
| 127 | +### Tracing |
| 128 | + |
| 129 | +All operations are traced using OpenTelemetry with the tracer name `io.sentrius.sso`. Trace spans include: |
| 130 | +- Operation type (search, get-issue, add-comment, assign-issue) |
| 131 | +- Query parameters |
| 132 | +- Result counts |
| 133 | +- Success/failure status |
| 134 | + |
| 135 | +## Future Enhancements |
| 136 | + |
| 137 | +1. **Multi-integration Support**: Allow specifying which JIRA instance to use |
| 138 | +2. **Enhanced JQL Support**: Full JQL query validation and optimization |
| 139 | +3. **Bulk Operations**: Support for bulk issue updates and assignments |
| 140 | +4. **Webhook Support**: Real-time notifications from JIRA |
| 141 | +5. **Custom Field Support**: Access to JIRA custom fields |
| 142 | +6. **Project-specific Operations**: Project creation, configuration management |
| 143 | + |
| 144 | +## Usage with Compliance Agents |
| 145 | + |
| 146 | +This proxy is designed to support compliance agents that need to: |
| 147 | +- Search for compliance-related issues |
| 148 | +- Create comments with compliance findings |
| 149 | +- Assign issues to appropriate team members |
| 150 | +- Track compliance status across JIRA projects |
| 151 | + |
| 152 | +Example agent workflow: |
| 153 | +1. Search for open compliance issues: `GET /api/v1/jira/rest/api/3/search?jql=project = COMPLIANCE AND status = Open` |
| 154 | +2. Add compliance assessment: `POST /api/v1/jira/rest/api/3/issue/COMPLIANCE-123/comment` |
| 155 | +3. Assign for remediation: `PUT /api/v1/jira/rest/api/3/issue/COMPLIANCE-123/assignee` |
| 156 | + |
| 157 | +## Testing |
| 158 | + |
| 159 | +Comprehensive test coverage is provided in `JiraProxyControllerTest.java`, including: |
| 160 | +- Authentication validation |
| 161 | +- Authorization checks |
| 162 | +- Error handling scenarios |
| 163 | +- Request/response validation |
0 commit comments