Skip to content

Commit 9330821

Browse files
rmarinnolehbozhokmoabu0xtinkle
authored
feat(jans-cedarling): implement sending logs to the lock server (#11161)
* chore(jans-cedarling): resolve clippy issues Signed-off-by: rmarinn <[email protected]> * feat: implement http_utils crate Signed-off-by: rmarinn <[email protected]> * feat: implement lock logger Signed-off-by: rmarinn <[email protected]> * refactor(lock-logger): use an StdOut logger instead of eprintln! Signed-off-by: rmarinn <[email protected]> * fix: build issue with WASM Signed-off-by: rmarinn <[email protected]> * chore: delete stray file Signed-off-by: rmarinn <[email protected]> * feat: add CEDARLING_LOCK_ACCEPT_INVALID_CERTS bootstrap property Signed-off-by: rmarinn <[email protected]> * docs: update cedarling-properties.md with new bootstrap prop Signed-off-by: rmarinn <[email protected]> * fix: build failing for WASM Signed-off-by: rmarinn <[email protected]> * fix: add additional scope when reigstering a lock client Signed-off-by: rmarinn <[email protected]> * feat: add an example that posts lock logs Signed-off-by: rmarinn <[email protected]> * refactor: remove the 'cedarling' scope for the DCR client Signed-off-by: rmarinn <[email protected]> * refactor: make lock_logger an optional dependency of log_strategy Signed-off-by: rmarinn <[email protected]> * refactor: rename LockLogger to LockService and move it to the lock mod Signed-off-by: rmarinn <[email protected]> * refactor: make SSA JWT optional for lock service DCR Signed-off-by: rmarinn <[email protected]> * refactor: rename `lock_logger`s to `lock_service` Signed-off-by: rmarinn <[email protected]> * fix(jans-cedarling): fix using reference counting for Logger Signed-off-by: Oleh Bozhok <[email protected]> * chore: resolve clippy issue by removing unused import Signed-off-by: rmarinn <[email protected]> * refactor: change default cedarling scope to 'cedarling' Signed-off-by: rmarinn <[email protected]> * docs: add a setup guide for lock integration Signed-off-by: rmarinn <[email protected]> * docs: change formatting of string example in the table Signed-off-by: rmarinn <[email protected]> * fix: request required scopes in DCR Signed-off-by: rmarinn <[email protected]> * chore: add some comments to the lock_integration example Signed-off-by: rmarinn <[email protected]> * refactor: added logging for sending logs to the lock server Signed-off-by: rmarinn <[email protected]> * feat: implement a shut_down function which pushes the buffered logs Signed-off-by: rmarinn <[email protected]> * chore: resolve clippy issues Signed-off-by: rmarinn <[email protected]> * fix: missing variable in WASM cfg scope Signed-off-by: rmarinn <[email protected]> * fix: generate go bindings for the ShutDown() function Signed-off-by: rmarinn <[email protected]> * fix: compilation issues with the wasm bindings Signed-off-by: rmarinn <[email protected]> * docs: improve cedarling/src/lock/mod.rs module documentation Signed-off-by: rmarinn <[email protected]> * fix(ci): cedarling test workflow failing because of missing clippy (#11427) install clippy so `cargo clippy -- -Dwarings` won't fail Signed-off-by: rmarinn <[email protected]> Co-authored-by: Mohammad Abudayyeh <[email protected]> * ci: add clippy Signed-off-by: moabu <[email protected]> * ci: fix rust2go version Signed-off-by: moabu <[email protected]> * chore: resolve formatting issue in the module doc Signed-off-by: rmarinn <[email protected]> --------- Signed-off-by: rmarinn <[email protected]> Signed-off-by: Oleh Bozhok <[email protected]> Signed-off-by: moabu <[email protected]> Co-authored-by: Oleh Bozhok <[email protected]> Co-authored-by: Mohammad Abudayyeh <[email protected]> Co-authored-by: 0xtinkle <[email protected]>
1 parent bdc3bd7 commit 9330821

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2252
-85
lines changed

.github/workflows/test-cedarling.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- name: Run Clippy on native target
2828
working-directory: jans-cedarling
2929
run: |
30+
rustup component add clippy
3031
cargo clippy -- -Dwarnings
3132
wasm_tests:
3233
runs-on: ubuntu-latest
@@ -51,6 +52,7 @@ jobs:
5152
- name: Run Clippy on WASM target
5253
working-directory: jans-cedarling
5354
run: |
55+
rustup component add clippy
5456
cargo clippy --target wasm32-unknown-unknown -- -Dwarnings
5557
python_tests:
5658
runs-on: ubuntu-latest
@@ -92,6 +94,7 @@ jobs:
9294
- name: Run build rust artifacts
9395
working-directory: jans-cedarling/bindings/cedarling_go
9496
run: |
97+
rustup component add clippy
9598
cargo build -r -p cedarling_go
9699
cp "../../target/release/libcedarling_go.so" "."
97100
- name: Install Go dependencies
64.1 KB
Loading

docs/cedarling/cedarling-lock-server.md

Lines changed: 250 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,259 @@ tags:
44
- lock server
55
---
66

7-
# Integrate Cedarling With Lock Server
7+
# Cedarling Lock Integration Setup Guide
88

9-
## This content is in progress
9+
For a Cedarling client to communicate with the Lock Server, it has to perform [Dynamic Client Registration **(DCR)**](https://datatracker.ietf.org/doc/html/rfc7591) with the Jans Auth Server.
1010

11-
The Janssen Project documentation is currently in development. Topic pages are being created in order of broadest relevance, and this page is coming in the near future.
11+
By default, clients cannot obtain the necessary scopes to interact with the lock server. Additional configuration is required on both the Auth Server and the client.
1212

13-
## Have questions in the meantime?
13+
This guide will walk you through the following setup processes:
1414

15-
While this documentation is in progress, you can ask questions through [GitHub Discussions](https://github.com/JanssenProject/jans/discussions) or the [community chat on Gitter](https://gitter.im/JanssenProject/Lobby). Any questions you have will help determine what information our documentation should cover.
15+
- [Auth Server Setup](#auth-server-setup)
16+
- [Client Setup](#client-setup)
1617

17-
## Want to contribute?
18+
---
19+
20+
## Auth Server Setup
21+
22+
### 1. Creating an SSA JWT
23+
24+
First, create a Software Statement Assertion (SSA) for your Cedarling client.
25+
26+
The easiest way to do this is to use the Jans TUI:
27+
28+
```sh
29+
jans tui
30+
```
31+
32+
Navigate to:
33+
`Auth Server` > `SSA` > `Add SSA`
34+
35+
![SSA Creation using the Jans TUI!](../assets/cedarling/ssa_creation_tui.png "SSA Creation using the Jans TUI")
36+
37+
When creating the SSA, ensure you:
38+
39+
- Add the `Client Credentials` grant type
40+
- Include the following software roles:
41+
- `https://jans.io/oauth/lock/log.write`
42+
- `https://jans.io/oauth/lock/health.write`
43+
- `https://jans.io/oauth/lock/telemetry.write`
44+
45+
After creation, **export the SSA token** and save it securely.
46+
47+
### 2. Setting up the Interception Script
48+
49+
Next, configure an [*interception script*](../janssen-server/developer/interception-scripts.md) to automatically add the required scopes when a Cedarling client registers.
50+
51+
In your server, create a script file at `/opt/jans/jetty/jans-auth/custom/script/add_cedarling_scopes.py` with the following content:
52+
53+
```py
54+
from io.jans.model.custom.script.type.client import ClientRegistrationType
55+
from io.jans.service.cdi.util import CdiUtil
56+
from io.jans.orm.util import ArrayHelper
57+
from io.jans.as.server.service import ScopeService
58+
from io.jans.as.model.util import JwtUtil
59+
60+
class ClientRegistration(ClientRegistrationType):
61+
def __init__(self, currentTimeMillis):
62+
self.currentTimeMillis = currentTimeMillis
63+
64+
def init(self, customScript, configurationAttributes):
65+
print "Cedarling Client registration. Initialization"
66+
67+
if (not configurationAttributes.containsKey("jwks_uri")):
68+
print "Cedarling Client registration. Initialization failed. Property jwks_uri is not specified"
69+
return False
70+
else:
71+
self.jwks_uri = configurationAttributes.get("jwks_uri").getValue2()
72+
73+
if (not configurationAttributes.containsKey("scope_list")):
74+
print "Cedarling Client registration. Initialization failed. Property scope_list is not specified"
75+
return False
76+
else:
77+
self.scope_list = configurationAttributes.get("scope_list").getValue2().split(" ")
78+
79+
if (not configurationAttributes.containsKey("trigger_scope")):
80+
print "Cedarling Client registration. Initialization failed. Property trigger_scope is not specified"
81+
return False
82+
else:
83+
self.trigger_scope = configurationAttributes.get("trigger_scope").getValue2()
84+
85+
# used to check if the scopes we're adding exists in the AS
86+
self.scopeService = CdiUtil.bean(ScopeService)
87+
88+
print "Cedarling Client registration. Initialized successfully"
89+
return True
90+
91+
def destroy(self, configurationAttributes):
92+
print "Cedarling Client registration. Destroy"
93+
print "Cedarling Client registration. Destroyed successfully"
94+
return True
95+
96+
def createClient(self, context):
97+
print "Cedarling Client registration. createClient"
98+
99+
# Check if the request has an SSA
100+
registerRequest = context.getRegisterRequest()
101+
ssa = registerRequest.getSoftwareStatement()
102+
if ssa == "":
103+
print "Cedarling Client registration. No SSA provided, defaulting"
104+
return True
105+
106+
# Check if the request has a trigger_scope (this is set as 'cedarling' by default) in the request.
107+
# The trigger_scope is used to determine if we should add the scopes needed by Cedarling to the
108+
# registering client.
109+
# request_scopes = ArrayHelper.toString(registerRequest.getScope())
110+
request_scopes = registerRequest.getScope()
111+
if self.trigger_scope not in request_scopes:
112+
print "Cedarling Client registration. the scope '%s' was not included in the request, defaulting" % self.trigger_scope
113+
return True
114+
115+
# add cedarling scopes
116+
client = context.getClient()
117+
scopes = client.getScopes()
118+
for scope in self.scope_list:
119+
foundScope = self.scopeService.getScopeById(scope)
120+
if foundScope is None:
121+
print "did not find scope '%s' in the AS" % scope
122+
return False
123+
if len(scopes) == 0:
124+
scopes = [foundScope.getDn()]
125+
else:
126+
scopes = ArrayHelper.addItemToStringArray(scopes, foundScope.getDn())
127+
128+
client.setScopes(scopes)
129+
130+
print "Cedarling Client registration. added Cedarling scopes"
131+
return True
132+
133+
def updateClient(self, context):
134+
print "Cedarling Client registration. UpdateClient method"
135+
pass
136+
137+
def getApiVersion(self):
138+
return 11
139+
140+
def getSoftwareStatementHmacSecret(self, context):
141+
return ""
142+
143+
def getSoftwareStatementJwks(self, context):
144+
print "SSA Cedarling Client registration. getting jwks from '%s'" % self.jwks_uri
145+
jwks = JwtUtil.getJSONWebKeys(self.jwks_uri)
146+
if jwks is None:
147+
print "SSA Cedarling Client registration. jwks not found"
148+
return jwks.toString()
149+
150+
def modifyPutResponse(self, responseAsJsonObject, executionContext):
151+
return False
152+
153+
def modifyReadResponse(self, responseAsJsonObject, executionContext):
154+
return False
155+
156+
def modifyPostResponse(self, responseAsJsonObject, executionContext):
157+
return False
158+
```
159+
160+
* *you can also find a copy of this script in [jans/jans-cedarling/lock-server-script/add_cedarling_scopes.py](../../jans-cedarling/lock-server-script/add_cedarling_scopes.py)*.
161+
162+
Next, create a JSON file named `script_schema.json` with the following content:
163+
164+
```json
165+
{
166+
"name": "add_cedarling_scopes",
167+
"aliases": null,
168+
"description": "A DCR script that adds the required scopes by a client to interact with the lock server",
169+
"scriptType": "client_registration",
170+
"programmingLanguage": "python",
171+
"moduleProperties": [],
172+
"configurationProperties": [
173+
{
174+
"value1": "jwks_uri",
175+
"value2": "https://demoexample.jans.io/jans-auth/restv1/jwks",
176+
"hide": false,
177+
"description": "JWKS URI used for the SSA validation"
178+
},
179+
{
180+
"value1": "scope_list",
181+
"value2": "https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/telemetry.write",
182+
"hide": false,
183+
"description": "space-separated scopes that will be added by the script"
184+
},
185+
{
186+
"value1": "trigger_scope",
187+
"value2": "cedarling",
188+
"hide": false,
189+
"description": "the scope that must be present for the script to run"
190+
}
191+
],
192+
"level": 100,
193+
"revision": 0,
194+
"enabled": true,
195+
"scriptError": null,
196+
"modified": false,
197+
"internal": false,
198+
"locationType": "file",
199+
"locationPath": "add_cedarling_scopes.py"
200+
}
201+
```
202+
203+
* *you can also find a copy of this schema in [jans/jans-cedarling/lock-server-script/script_schema.json](../../jans-cedarling/lock-server-script/script_schema.json)*.
204+
205+
> Note:
206+
>
207+
> Do not change the field ordering; The Jans server expects a specific structure.
208+
209+
Finally, register the script with the Auth Server:
210+
211+
```sh
212+
jans cli --operation-id post-config-scripts --data ./script_schema.json
213+
```
214+
215+
### 3. Testing the Setup
216+
217+
You can verify the setup by initializing a client registration with your SSA:
218+
219+
```sh
220+
curl -kX POST https://demoexample.jans.io/jans-auth/restv1/register \
221+
-H "Content-Type: application/json" \
222+
-d '{
223+
"token_endpoint_auth_method": "client_secret_basic",
224+
"grant_types": ["client_credentials"],
225+
"client_name": "cedarling-test",
226+
"access_token_as_jwt": true,
227+
"scope": "cedarling",
228+
"software_statement": "<YOUR_SSA_HERE>"
229+
}'
230+
```
231+
232+
A successful response will contain the following scopes:
233+
234+
```json
235+
{
236+
"scope": "https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/telemetry.write"
237+
}
238+
```
239+
240+
> Note:
241+
>
242+
> If you want to learn more about configuring the example interception script, see the [reference](../janssen-server/developer/interception-scripts.md).
243+
244+
---
245+
246+
## Client Setup
247+
248+
To enable Lock Server integration in the Cedarling client, configure the appropriate [bootstrap properties](./cedarling-properties.md).
249+
250+
Here's a table of the available properties:
18251

19-
If you have content you'd like to contribute to this page in the meantime, you can get started with our [Contribution guide](https://docs.jans.io/head/CONTRIBUTING/).
252+
| Property | Description | Allowed Values | Default |
253+
| --- | --- | --- | --- |
254+
| `CEDARLING_LOCK` | Toggles the all the Lock Server integration features. | `enabled`, `disabled` | `disabled` |
255+
| `CEDARLING_LOCK_SERVER_CONFIGURATION_URI` | URI to fetch Lock Server metadata (`.well-known/lock-master-configuration`). Required if `CEDARLING_LOCK` is `enabled`. | String | `""` |
256+
| `CEDARLING_LOCK_DYNAMIC_CONFIGURATION` (WIP) | Toggles listening for Server-Sent Events (SSE) config updates. | `enabled`, `disabled` | `disabled` |
257+
| `CEDARLING_LOCK_SSA_JWT` | SSA JWT used for DCR. This is required if you followed the [auth server setup](#auth-server-setup). | String | `""` |
258+
| `CEDARLING_LOCK_LOG_INTERVAL` | Frequency (in seconds) of sending log messages to the Lock Server. `0` disables transmission. | uint | `0` |
259+
| `CEDARLING_LOCK_HEALTH_INTERVAL` (WIP) | Frequency (in seconds) of sending health messages to the Lock Server. `0` disables transmission. | uint | `0` |
260+
| `CEDARLING_LOCK_TELEMETRY_INTERVAL` (WIP) | Frequency (in seconds) of sending telemetry messages to the Lock Server. `0` disables transmission. | uint | `0` |
261+
| `CEDARLING_LOCK_LISTEN_SSE` (WIP) | Toggles listening for updates from the Lock Server via SSE. | `enabled`, `disabled` | `disabled` |
262+
| `CEDARLING_LOCK_ACCEPT_INVALID_CERTS` | Allows connection to servers with invalid certificates (for testing purposes only; not available for WASM builds).| `enabled`, `disabled` | `disabled` |

docs/cedarling/cedarling-properties.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ These Bootstrap Properties control default application level behavior.
1414

1515
* **`CEDARLING_APPLICATION_NAME`** : Human friendly identifier for this application
1616
* **`CEDARLING_POLICY_STORE_URI`** : Location of policy store JSON, used if policy store is not local.
17-
* **`CEDARLING_POLICY_STORE_ID`** : The identifier of the policy store in case there is more then one policy_store_id in the policy store.
17+
* **`CEDARLING_POLICY_STORE_ID`** : The identifier of the policy store in case there is more than one policy_store_id in the policy store.
1818
* **`CEDARLING_USER_AUTHZ`** : When `enabled`, Cedar engine authorization is queried for a User principal.
1919
* **`CEDARLING_WORKLOAD_AUTHZ`** : When `enabled`, Cedar engine authorization is queried for a Workload principal.
2020
* **`CEDARLING_PRINCIPAL_BOOLEAN_OPERATION`** : property specifies what boolean operation to use for the `USER` and `WORKLOAD` when making authz (authorization) decisions. [See here](#user-workload-boolean-operation).
@@ -39,22 +39,25 @@ These Bootstrap Properties control default application level behavior.
3939
* **`CEDARLING_LOCAL_JWKS`** : JWKS file with public keys
4040
* **`CEDARLING_POLICY_STORE_LOCAL`** : JSON object as string with policy store. You can use [this](https://jsontostring.com/) converter.
4141
* **`CEDARLING_POLICY_STORE_LOCAL_FN`** : Local file with JSON object with policy store
42-
* **`CEDARLING_JWT_SIG_VALIDATION`** : `enabled` | `disabled` -- Whether to check the signature of all JWT tokens. This requires an `iss` is present.
42+
* **`CEDARLING_JWT_SIG_VALIDATION`** : `enabled` | `disabled` -- Whether to check the signature of all JWT tokens. This requires an `iss` is present.
4343
* **`CEDARLING_JWT_STATUS_VALIDATION`** : `enabled` | `disabled` -- Whether to check the status of the JWT. On startup, the Cedarling should fetch and retreive the latest Status List JWT from the `.well-known/openid-configuration` via the `status_list_endpoint` claim and cache it. See the [IETF Draft](https://datatracker.ietf.org/doc/draft-ietf-oauth-status-list/) for more info.
4444
* **`CEDARLING_JWT_SIGNATURE_ALGORITHMS_SUPPORTED`** : Only tokens signed with these algorithms are acceptable to the Cedarling.
45-
* **`CEDARLING_ID_TOKEN_TRUST_MODE`** : `Strict` | `None`. Varying levels of validations based on the preference of the developer.
45+
* **`CEDARLING_ID_TOKEN_TRUST_MODE`** : `Strict` | `None`. Varying levels of validations based on the preference of the developer.
4646
`Strict` mode requires (1) id_token `aud` matches the access_token `client_id`; (2) if a Userinfo token is present, the `sub` matches the id_token, and that the `aud` matches the access token client_id.
4747

48-
**The following bootstrap properties are only needed for enterprise deployments.**
48+
**The following bootstrap properties are only needed for the Lock Server Integration.**
4949

5050
* **`CEDARLING_LOCK`** : `enabled` | `disabled`. If `enabled`, the Cedarling will connect to the Lock Server for policies, and subscribe for SSE events.
5151
* **`CEDARLING_LOCK_SERVER_CONFIGURATION_URI`** : Required if `LOCK` == `enabled`. URI where Cedarling can get JSON file with all required metadata about the Lock Server, i.e. `.well-known/lock-master-configuration`.
5252
* **`CEDARLING_LOCK_DYNAMIC_CONFIGURATION`** : `enabled` | `disabled`, controls whether Cedarling should listen for SSE config updates.
5353
* **`CEDARLING_LOCK_SSA_JWT`** : SSA for DCR in a Lock Server deployment. The Cedarling will validate this SSA JWT prior to DCR.
54-
* **`CEDARLING_LOCK_LOG_INTERVAL`** : How often to send log messages to Lock Server (0 to turn off trasmission).
54+
* **`CEDARLING_LOCK_LOG_INTERVAL`** : How often to send log messages to Lock Server (0 to turn off transmission).
5555
* **`CEDARLING_LOCK_HEALTH_INTERVAL`** : How often to send health messages to Lock Server (0 to turn off transmission).
5656
* **`CEDARLING_LOCK_TELEMETRY_INTERVAL`** : How often to send telemetry messages to Lock Server (0 to turn off transmission).
57-
* **`CEDARLING_LOCK_LISTEN_SSE`** : `enabled` | `disabled`: controls whether Cedarling should listen for updates from the Lock Server.
57+
* **`CEDARLING_LOCK_LISTEN_SSE`** : `enabled` | `disabled`: controls whether Cedarling should listen for updates from the Lock Server.
58+
* **`CEDARLING_LOCK_ACCEPT_INVALID_CERTS`** : `enabled` | `disabled`: Allows interaction with a Lock server with invalid certificates. Mainly used for testing. Doesn't work for WASM builds.
59+
60+
controls whether Cedarling should listen for updates from the Lock Server.
5861

5962
## Required properties for startup
6063

jans-cedarling/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["bindings/*", "cedarling", "sparkv", "test_utils"]
3+
members = ["bindings/*", "cedarling", "http_utils", "sparkv", "test_utils"]
44

55
[workspace.dependencies]
66
serde = { version = "1.0", features = ["derive"] }
@@ -10,13 +10,15 @@ sparkv = { path = "sparkv" }
1010
jsonwebtoken = "9.3.0"
1111
jsonwebkey = "0.3.5"
1212
chrono = "0.4"
13+
http_utils = { path = "http_utils" }
1314
cedarling = { path = "cedarling" }
1415
test_utils = { path = "test_utils" }
1516
wasm-bindgen = "0.2"
1617
wasm-bindgen-futures = "0.4"
1718
web-sys = "0.3"
1819
serde-wasm-bindgen = "0.6"
1920
tokio = "1.42.0"
21+
tokio-util = "0.7.15"
2022

2123

2224
[profile.release]

jans-cedarling/bindings/cedarling_go/cedarling.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ func (c *Cedarling) GetLogsByRequestId(request_id string) []string {
109109
func (c *Cedarling) GetLogsByRequestIdAndTag(request_id string, tag string) []string {
110110
return internal.CallGetLogsByRequestIdAndTag(c.instance_id, request_id, tag)
111111
}
112+
113+
func (c *Cedarling) ShutDown() {
114+
internal.CallShutDown(c.instance_id)
115+
}

jans-cedarling/bindings/cedarling_go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/JanssenProject/jans/jans-cedarling/bindings/cedarling_go
22

33
go 1.20
44

5-
require github.com/ihciah/rust2go v0.0.0-20250312161018-7394c455c373
5+
require github.com/ihciah/rust2go v0.0.0-20250427082441-4d6d8d2c2959

jans-cedarling/bindings/cedarling_go/internal/gen.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const void c_G2RCall_get_log_ids(const void*, const void*);
4040
const void c_G2RCall_get_logs_by_tag(const void*, const void*);
4141
const void c_G2RCall_get_logs_by_request_id(const void*, const void*);
4242
const void c_G2RCall_get_logs_by_request_id_and_tag(const void*, const void*);
43+
const void c_G2RCall_shut_down(const void*);
4344
*/
4445
import "C"
4546
import (
@@ -418,3 +419,11 @@ func (G2RCallImpl) get_logs_by_request_id_and_tag(instance_id *uint, id *string,
418419
asmcall.CallFuncG0P1(unsafe.Pointer(C.c_rust2go_internal_drop), unsafe.Pointer(_internal_slot[1]))
419420
return val
420421
}
422+
func (G2RCallImpl) shut_down(instance_id *uint) {
423+
_internal_params := [1]unsafe.Pointer{}
424+
instance_id_ref, instance_id_buffer := cvt_ref(cntC_uintptr_t, refC_uintptr_t)(instance_id)
425+
_internal_params[0] = unsafe.Pointer(&instance_id_ref)
426+
asmcall.CallFuncG0P1(unsafe.Pointer(C.c_G2RCall_shut_down), unsafe.Pointer(&_internal_params))
427+
runtime.KeepAlive(_internal_params)
428+
runtime.KeepAlive(instance_id_buffer)
429+
}

jans-cedarling/bindings/cedarling_go/internal/methods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ func CallGetLogsByRequestIdAndTag(instance_id uint, request_id string, tag strin
9090
logs := G2R.get_logs_by_request_id_and_tag(&instance_id, &request_id, &tag)
9191
return logs
9292
}
93+
94+
func CallShutDown(instance_id uint) {
95+
G2R.shut_down(&instance_id)
96+
}

0 commit comments

Comments
 (0)