Skip to content

Commit e9fea40

Browse files
authored
feat(terraform-provider): add agama and config data sources (#12855)
* fix: update terraform Signed-off-by: moabu <47318409+moabu@users.noreply.github.com> * fix: add agama check 1. Agama Syntax Check Data Source (jans_agama_syntax_check) Validates Agama DSL code syntax before deployment Uses the /api/v1/agama/syntax-check/{qname} endpoint Returns valid (boolean) and message (string) for syntax validation results 2. Database Configuration Data Source (jans_database_configuration) Retrieves database schema for non-LDAP backends (PostgreSQL, etc.) Uses the /api/v1/config/database endpoint Returns structured table/field information with deterministic ordering Also provides raw JSON for advanced processing Signed-off-by: moabu <47318409+moabu@users.noreply.github.com> * fix: address comments Signed-off-by: moabu <47318409+moabu@users.noreply.github.com> --------- Signed-off-by: moabu <47318409+moabu@users.noreply.github.com>
1 parent 7873d25 commit e9fea40

23 files changed

+3297
-2326
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
page_title: "jans_agama_repository Data Source - terraform-provider-jans"
3+
subcategory: ""
4+
description: |-
5+
Data source for retrieving Agama flow repositories from Janssen server
6+
---
7+
8+
# jans_agama_repository (Data Source)
9+
10+
Data source for retrieving Agama flow repositories from the Janssen server.
11+
Agama is a domain-specific language for building authentication flows.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "jans_agama_repository" "all" {
17+
}
18+
19+
output "agama_repos" {
20+
value = data.jans_agama_repository.all.repositories
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Read-Only
28+
29+
- `id` (String) The ID of this resource.
30+
- `repositories` (List of Object) List of Agama repositories (see [below for nested schema](#nestedatt--repositories))
31+
32+
<a id="nestedatt--repositories"></a>
33+
34+
### Nested Schema for `repositories`
35+
36+
Read-Only:
37+
38+
- `description` (String) Description of the repository
39+
- `metadata` (String) Repository metadata as JSON string
40+
- `name` (String) Repository name
41+
- `url` (String) Repository URL
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
page_title: "jans_agama_syntax_check Data Source - terraform-provider-jans"
3+
subcategory: ""
4+
description: |-
5+
Data source for validating Agama flow code syntax
6+
---
7+
8+
# jans_agama_syntax_check (Data Source)
9+
10+
Data source for validating Agama DSL code syntax. This allows you to check if
11+
Agama flow code is syntactically correct before deploying it.
12+
13+
Agama is a domain-specific language (DSL) for building authentication flows
14+
in the Janssen identity platform.
15+
16+
## Example Usage
17+
18+
```terraform
19+
data "jans_agama_syntax_check" "my_flow" {
20+
flow_name = "my.authentication.Flow"
21+
code = <<-EOT
22+
Flow my.authentication.Flow
23+
Basepath ""
24+
25+
in = { name: "" }
26+
27+
Finish in.name
28+
EOT
29+
}
30+
31+
output "is_valid" {
32+
value = data.jans_agama_syntax_check.my_flow.valid
33+
}
34+
35+
output "validation_message" {
36+
value = data.jans_agama_syntax_check.my_flow.message
37+
}
38+
```
39+
40+
<!-- schema generated by tfplugindocs -->
41+
## Schema
42+
43+
### Required
44+
45+
- `code` (String) The Agama DSL code to validate
46+
- `flow_name` (String) The name of the Agama flow to check
47+
48+
### Read-Only
49+
50+
- `id` (String) The ID of this resource.
51+
- `message` (String) Syntax check result message. Empty or 'Syntax is OK' for valid code
52+
- `valid` (Boolean) Whether the Agama code syntax is valid
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
page_title: "jans_database_configuration Data Source - terraform-provider-jans"
3+
subcategory: ""
4+
description: |-
5+
Data source for retrieving database schema configuration
6+
---
7+
8+
# jans_database_configuration (Data Source)
9+
10+
Data source for retrieving the database schema configuration from the Janssen server.
11+
This provides information about all database tables and their field definitions,
12+
useful for understanding the data model of non-LDAP database backends.
13+
14+
## Example Usage
15+
16+
```terraform
17+
data "jans_database_configuration" "all" {
18+
}
19+
20+
output "table_count" {
21+
value = length(data.jans_database_configuration.all.tables)
22+
}
23+
24+
output "schema_json" {
25+
value = data.jans_database_configuration.all.schema_json
26+
}
27+
```
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Read-Only
33+
34+
- `id` (String) The ID of this resource.
35+
- `schema_json` (String) Full database schema as JSON string for advanced processing
36+
- `tables` (List of Object) List of database tables and their schema (see [below for nested schema](#nestedatt--tables))
37+
38+
<a id="nestedatt--tables"></a>
39+
### Nested Schema for `tables`
40+
41+
Read-Only:
42+
43+
- `fields` (List of Object) List of fields in the table (see [below for nested schema](#nestedatt--tables--fields))
44+
- `name` (String) Table name
45+
46+
<a id="nestedatt--tables--fields"></a>
47+
### Nested Schema for `tables.fields`
48+
49+
Read-Only:
50+
51+
- `def_name` (String) Default/definition name of the field
52+
- `multi_valued` (Boolean) Whether the field supports multiple values
53+
- `name` (String) Field name in the database
54+
- `type` (String) Field data type (varchar, timestamp, jsonb, etc.)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
page_title: "jans_feature_flags Data Source - terraform-provider-jans"
3+
subcategory: ""
4+
description: |-
5+
Data source for retrieving feature flags configured for Janssen authorization server
6+
---
7+
8+
# jans_feature_flags (Data Source)
9+
10+
Data source for retrieving feature flags configured for Janssen authorization server.
11+
Feature flags control which features are enabled or disabled in the auth server.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "jans_feature_flags" "all" {
17+
}
18+
19+
output "enabled_features" {
20+
value = data.jans_feature_flags.all.flags
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Read-Only
28+
29+
- `flags` (List of String) List of feature flags enabled on the Janssen authorization server
30+
- `id` (String) The ID of this resource.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
page_title: "jans_service_status Data Source - terraform-provider-jans"
3+
subcategory: ""
4+
description: |-
5+
Data source for retrieving service status from Janssen server
6+
---
7+
8+
# jans_service_status (Data Source)
9+
10+
Data source for retrieving detailed service status information from the Janssen server.
11+
This provides granular health information about individual services.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "jans_service_status" "all" {
17+
}
18+
19+
output "service_status" {
20+
value = data.jans_service_status.all.status
21+
}
22+
23+
data "jans_service_status" "auth" {
24+
service = "jans-auth"
25+
}
26+
```
27+
28+
<!-- schema generated by tfplugindocs -->
29+
## Schema
30+
31+
### Optional
32+
33+
- `service` (String) Service name to check status. Use 'all' to get status of all services. Default: "all"
34+
35+
### Read-Only
36+
37+
- `id` (String) The ID of this resource.
38+
- `status` (Map of String) Map of service names to their status (Running, Down, Not present)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package jans
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
type AgamaRepository struct {
10+
Name string `json:"name,omitempty"`
11+
Description string `json:"description,omitempty"`
12+
URL string `json:"url,omitempty"`
13+
Metadata json.RawMessage `json:"metadata,omitempty"`
14+
}
15+
16+
func (c *Client) GetAgamaRepositories(ctx context.Context) ([]AgamaRepository, error) {
17+
18+
token, err := c.ensureToken(ctx, "https://jans.io/oauth/config/agama-repo.readonly")
19+
if err != nil {
20+
return nil, fmt.Errorf("failed to get token: %w", err)
21+
}
22+
23+
var repos []AgamaRepository
24+
25+
if err := c.get(ctx, "/jans-config-api/api/v1/agama-repo", token, "https://jans.io/oauth/config/agama-repo.readonly", &repos); err != nil {
26+
return nil, fmt.Errorf("failed to get agama repositories: %w", err)
27+
}
28+
29+
return repos, nil
30+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package jans
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/url"
7+
"strings"
8+
)
9+
10+
type AgamaSyntaxCheckResult struct {
11+
FlowName string `json:"flow_name,omitempty"`
12+
Code string `json:"code,omitempty"`
13+
Valid bool `json:"valid,omitempty"`
14+
Message string `json:"message,omitempty"`
15+
}
16+
17+
func (c *Client) CheckAgamaSyntax(ctx context.Context, flowName string, code string) (*AgamaSyntaxCheckResult, error) {
18+
19+
flowName = strings.TrimSpace(flowName)
20+
if flowName == "" {
21+
return nil, fmt.Errorf("flowName must be provided")
22+
}
23+
24+
code = strings.TrimSpace(code)
25+
if code == "" {
26+
return nil, fmt.Errorf("code must be provided")
27+
}
28+
29+
token, err := c.ensureToken(ctx, "https://jans.io/oauth/config/agama.readonly")
30+
if err != nil {
31+
return nil, fmt.Errorf("failed to get token: %w", err)
32+
}
33+
34+
path := fmt.Sprintf("/jans-config-api/api/v1/agama/syntax-check/%s", url.PathEscape(flowName))
35+
36+
var message string
37+
if err := c.postText(ctx, path, token, code, &message); err != nil {
38+
return nil, fmt.Errorf("syntax check request failed: %w", err)
39+
}
40+
41+
result := &AgamaSyntaxCheckResult{
42+
FlowName: flowName,
43+
Code: code,
44+
Valid: message == "" || strings.Contains(message, "Syntax is OK"),
45+
Message: message,
46+
}
47+
48+
return result, nil
49+
}
50+
51+
func (c *Client) postText(ctx context.Context, path, token, req string, resp any) error {
52+
53+
params := requestParams{
54+
method: "POST",
55+
path: path,
56+
contentType: "text/plain",
57+
accept: "application/json",
58+
token: token,
59+
payload: []byte(req),
60+
resp: resp,
61+
}
62+
63+
return c.request(ctx, params)
64+
}

terraform-provider-jans/jans/app_configuration.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ type AppConfiguration struct {
128128
IntrospectionEndpoint string `schema:"introspection_endpoint" json:"introspectionEndpoint"`
129129
ParEndpoint string `schema:"par_endpoint" json:"parEndpoint"`
130130
RequirePar bool `schema:"require_par" json:"requirePar"`
131+
ParForbidPublicClient bool `schema:"par_forbid_public_client" json:"parForbidPublicClient"`
132+
JwtGrantAllowUserByUidInAssertion bool `schema:"jwt_grant_allow_user_by_uid_in_assertion" json:"jwtGrantAllowUserByUidInAssertion"`
133+
AllowClientAssertionAudWithoutStrictIssuerMatch bool `schema:"allow_client_assertion_aud_without_strict_issuer_match" json:"allowClientAssertionAudWithoutStrictIssuerMatch"`
134+
SkipSessionAuthnTimeCheckDuringPromptLogin bool `schema:"skip_session_authn_time_check_during_prompt_login" json:"skipSessionAuthnTimeCheckDuringPromptLogin"`
135+
SessionAuthnTimeCheckDuringPromptLoginThresholdMs int `schema:"session_authn_time_check_during_prompt_login_threshold_ms" json:"sessionAuthnTimeCheckDuringPromptLoginThresholdMs"`
136+
UppercaseResponseKeysInAccountAccessConsent bool `schema:"uppercase_response_keys_in_account_access_consent" json:"uppercaseResponseKeysInAccountAccessConsent"`
131137
DeviceAuthzEndpoint string `schema:"device_authz_endpoint" json:"deviceAuthzEndpoint"`
132138
MtlsAuthorizationEndpoint string `schema:"mtls_authorization_endpoint" json:"mtlsAuthorizationEndpoint"`
133139
MtlsAuthorizationChallengeEndpoint string `schema:"mtls_authorization_challenge_endpoint" json:"mtlsAuthorizationChallengeEndpoint"`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package jans
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
type DatabaseSchemaField struct {
9+
Name string `json:"name,omitempty"`
10+
DefName string `json:"defName,omitempty"`
11+
Type string `json:"type,omitempty"`
12+
MultiValued bool `json:"multiValued,omitempty"`
13+
}
14+
15+
type DatabaseSchema map[string]map[string]DatabaseSchemaField
16+
17+
func (c *Client) GetDatabaseSchema(ctx context.Context) (DatabaseSchema, error) {
18+
19+
token, err := c.ensureToken(ctx, "https://jans.io/oauth/config/database.readonly")
20+
if err != nil {
21+
return nil, fmt.Errorf("failed to get token: %w", err)
22+
}
23+
24+
var schema DatabaseSchema
25+
if err := c.get(ctx, "/jans-config-api/api/v1/config/database", token, "https://jans.io/oauth/config/database.readonly", &schema); err != nil {
26+
return nil, fmt.Errorf("failed to get database schema: %w", err)
27+
}
28+
29+
return schema, nil
30+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package jans
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
func (c *Client) GetFeatureFlags(ctx context.Context) ([]string, error) {
9+
10+
token, err := c.ensureToken(ctx, "https://jans.io/oauth/jans-auth-server/config/properties.readonly")
11+
if err != nil {
12+
return nil, fmt.Errorf("failed to get token: %w", err)
13+
}
14+
15+
var flags []string
16+
17+
if err := c.get(ctx, "/jans-config-api/api/v1/jans-auth-server/config/feature-flags", token, "https://jans.io/oauth/jans-auth-server/config/properties.readonly", &flags); err != nil {
18+
return nil, fmt.Errorf("failed to get feature flags: %w", err)
19+
}
20+
21+
return flags, nil
22+
}

0 commit comments

Comments
 (0)