-
Notifications
You must be signed in to change notification settings - Fork 2
docs: add DB2 for i (AS/400) connection guidance #145
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
afalahi
wants to merge
5
commits into
main
Choose a base branch
from
ali/db2-ibmi-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+304
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
43e614b
docs: add DB2 for i (AS/400) connection guidance
afalahi 3067c8a
docs: document Db2 Connect license sourcing and SQL1598N remediation
afalahi 7d25429
docs: add example configs for DB2 LUW and DB2 for i
afalahi e60dcd5
docs: note Db2 Connect license version matching and db2cli validate
afalahi fd05add
docs: normalize nullable columns in DB2 for i example query
afalahi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| --- | ||
| # Application name for this connector configuration | ||
| app_name: DB2 for i Test | ||
|
|
||
| # Connection settings for DB2 for i (AS/400 / IBM i). | ||
| # Requires a binary built with `make build-db2` AND a customer-supplied Db2 Connect | ||
| # license in clidriver/license/ — connections fail with SQL1598N without it. | ||
| # See the "DB2 for i (AS/400)" section in docs/db2.md. | ||
| connect: | ||
| # Port 446 is the DDM/DRDA service (NOT 8471, which is the IBM i Access host server). | ||
| # DB_RDB_NAME is the relational database name from WRKRDBDIRE (*LOCAL entry) — usually | ||
| # the system name, never an application library. CurrentSchema sets the default | ||
| # library for unqualified table names; queries below qualify QSYS2 explicitly, so it | ||
| # only matters for application-table queries you add. | ||
| dsn: "db2://${DB_HOST}:446/${DB_RDB_NAME}?CurrentSchema=${DB_LIBRARY}" | ||
| # Username and password are provided separately so they can be properly URL encoded. | ||
| user: "${DB_USER}" | ||
| password: "${DB_PASSWORD}" | ||
|
|
||
| # This example is sync-only. Provisioning user profiles or group membership on IBM i | ||
| # is done with CL commands (CRTUSRPRF/CHGUSRPRF), not SQL — wire those through | ||
| # CALL QSYS2.QCMDEXC(...) only with care, since GRPPRF/SUPGRPPRF changes replace the | ||
| # current values rather than appending. | ||
| resource_types: | ||
| # IBM i user profiles | ||
| user: | ||
| name: "User" | ||
| description: "A user profile on the IBM i system" | ||
| list: | ||
| # QSYS2.USER_INFO is the SQL catalog view over user profiles. | ||
| # Group profiles also appear here; GROUP_ID_NUMBER > 0 filters them out of the | ||
| # user list (they are synced as groups below). OFFSET/FETCH needs IBM i 7.3+. | ||
| # Nullable columns are normalized in SQL (COALESCE) so CEL expressions only ever | ||
| # see strings — CEL operations on NULL or timestamp values fail with | ||
| # "no such overload". | ||
| query: | | ||
| SELECT | ||
| AUTHORIZATION_NAME AS "username", | ||
| STATUS AS "status", | ||
| COALESCE(TEXT_DESCRIPTION, '') AS "description", | ||
| USER_CLASS_NAME AS "user_class", | ||
| COALESCE(VARCHAR(PREVIOUS_SIGNON), '') AS "last_signon" | ||
| FROM QSYS2.USER_INFO | ||
| WHERE GROUP_ID_NUMBER = 0 | ||
| ORDER BY AUTHORIZATION_NAME | ||
| OFFSET ?<Offset> ROWS FETCH NEXT ?<Limit> ROWS ONLY | ||
| pagination: | ||
| strategy: "offset" | ||
| primary_key: "username" | ||
| map: | ||
| id: ".username" | ||
| display_name: ".username" | ||
| description: ".description" | ||
| traits: | ||
| user: | ||
| # *ENABLED / *DISABLED from the profile status | ||
| status: '.status == "*ENABLED" ? "enabled" : "disabled"' | ||
| login: ".username" | ||
| last_login: ".last_signon" | ||
| profile: | ||
| username: ".username" | ||
| user_class: ".user_class" | ||
|
|
||
| # IBM i group profiles (a group is a user profile with a group ID) | ||
| group: | ||
| name: "Group" | ||
| description: "A group profile on the IBM i system" | ||
| list: | ||
| query: | | ||
| SELECT DISTINCT | ||
| GROUP_PROFILE_NAME AS "group_name" | ||
| FROM QSYS2.GROUP_PROFILE_ENTRIES | ||
| ORDER BY GROUP_PROFILE_NAME | ||
| map: | ||
| id: ".group_name" | ||
| display_name: ".group_name" | ||
| description: "" | ||
| traits: | ||
| group: | ||
| profile: | ||
| group_name: ".group_name" | ||
| static_entitlements: | ||
| - id: "member" | ||
| display_name: "resource.DisplayName + ' Group Member'" | ||
| description: "'Member of the ' + resource.DisplayName + ' group profile'" | ||
| purpose: "assignment" | ||
| grantable_to: | ||
| - "user" | ||
| grants: | ||
| # QSYS2.GROUP_PROFILE_ENTRIES lists every (group profile, member) pair, | ||
| # covering both the primary group (GRPPRF) and supplemental groups (SUPGRPPRF). | ||
| - query: | | ||
| SELECT | ||
| GROUP_PROFILE_NAME AS "group_name", | ||
| USER_PROFILE_NAME AS "username" | ||
| FROM QSYS2.GROUP_PROFILE_ENTRIES | ||
| map: | ||
| - skip_if: ".group_name != resource.ID" | ||
| principal_id: ".username" | ||
| principal_type: "user" | ||
| entitlement_id: "member" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| --- | ||
| # Application name for this connector configuration | ||
| app_name: DB2 LUW Test | ||
|
|
||
| # Connection settings for DB2 LUW (Linux/Unix/Windows). | ||
| # Requires a binary built with `make build-db2` — see docs/db2.md. | ||
| connect: | ||
| # Data Source Name (DSN) — default DB2 LUW port is 50000. | ||
| # Extra CLI keywords can be passed as query parameters, e.g. ?CurrentSchema=MYSCHEMA | ||
| dsn: "db2://${DB_HOST}:${DB_PORT}/${DB_NAME}" | ||
| # Username and password are provided separately so they can be properly URL encoded. | ||
| user: "${DB_USER}" | ||
| password: "${DB_PASSWORD}" | ||
|
|
||
| # Definition of different resource types managed by this connector | ||
| resource_types: | ||
| # DB2 LUW does not store users itself (authentication is OS/LDAP); the closest | ||
| # identity inventory is the set of authorization IDs that hold database authorities. | ||
| user: | ||
| name: "User" | ||
| description: "An authorization ID with database authorities in DB2" | ||
| list: | ||
| # SYSCAT.DBAUTH lists database-level authorities; GRANTEETYPE 'U' = user IDs | ||
| query: | | ||
| SELECT DISTINCT | ||
| GRANTEE AS "username" | ||
| FROM SYSCAT.DBAUTH | ||
| WHERE GRANTEETYPE = 'U' | ||
| ORDER BY GRANTEE | ||
| OFFSET ?<Offset> ROWS FETCH NEXT ?<Limit> ROWS ONLY | ||
| pagination: | ||
| strategy: "offset" | ||
| primary_key: "username" | ||
| map: | ||
| id: ".username" | ||
| display_name: ".username" | ||
| description: "" | ||
| traits: | ||
| user: | ||
| login: ".username" | ||
| profile: | ||
| username: ".username" | ||
|
|
||
| # Roles defined in the database (CREATE ROLE) | ||
| role: | ||
| name: "Role" | ||
| description: "A role within the DB2 database" | ||
| list: | ||
| query: | | ||
| SELECT | ||
| ROLENAME AS "role_name" | ||
| FROM SYSCAT.ROLES | ||
| ORDER BY ROLENAME | ||
| map: | ||
| id: ".role_name" | ||
| display_name: ".role_name" | ||
| description: "" | ||
| traits: | ||
| role: | ||
| profile: | ||
| role_name: ".role_name" | ||
| static_entitlements: | ||
| - id: "assigned" | ||
| display_name: "resource.DisplayName + ' Role Member'" | ||
| description: "'Member of the ' + resource.DisplayName + ' role'" | ||
| purpose: "assignment" | ||
| grantable_to: | ||
| - "user" | ||
| provisioning: | ||
| vars: | ||
| principal_name: principal.ID | ||
| role_name: resource.ID | ||
| grant: | ||
| no_transaction: true | ||
| queries: | ||
| # GRANT is DDL — parameter binding is not allowed, so identifiers are | ||
| # inlined with ?<...|unquoted> (values are sanitized, never escaped). | ||
| - | | ||
| GRANT ROLE ?<role_name|unquoted> TO USER ?<principal_name|unquoted> | ||
| revoke: | ||
| no_transaction: true | ||
| queries: | ||
| - | | ||
| REVOKE ROLE ?<role_name|unquoted> FROM USER ?<principal_name|unquoted> | ||
| - id: "admin" | ||
| display_name: "resource.DisplayName + ' Role Admin'" | ||
| description: "'Can administer the ' + resource.DisplayName + ' role'" | ||
| purpose: "permission" | ||
| grantable_to: | ||
| - "user" | ||
| provisioning: | ||
| vars: | ||
| principal_name: principal.ID | ||
| role_name: resource.ID | ||
| grant: | ||
| no_transaction: true | ||
| queries: | ||
| - | | ||
| GRANT ROLE ?<role_name|unquoted> TO USER ?<principal_name|unquoted> WITH ADMIN OPTION | ||
| revoke: | ||
| no_transaction: true | ||
| queries: | ||
| - | | ||
| REVOKE ADMIN OPTION FOR ROLE ?<role_name|unquoted> FROM USER ?<principal_name|unquoted> | ||
| grants: | ||
| # SYSCAT.ROLEAUTH holds role memberships; ADMIN = 'Y' marks WITH ADMIN OPTION | ||
| - query: | | ||
| SELECT | ||
| GRANTEE AS "username", | ||
| ROLENAME AS "role_name", | ||
| ADMIN AS "admin" | ||
| FROM SYSCAT.ROLEAUTH | ||
| WHERE GRANTEETYPE = 'U' | ||
| map: | ||
| - skip_if: ".role_name != resource.ID" | ||
| principal_id: ".username" | ||
| principal_type: "user" | ||
| entitlement_id: "assigned" | ||
| - skip_if: ".role_name != resource.ID || .admin != 'Y'" | ||
| principal_id: ".username" | ||
| principal_type: "user" | ||
| entitlement_id: "admin" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Consider
?<role_name|identifier>/?<principal_name|identifier>here (and in the revoke/admin queries) instead ofunquoted. This connector's own token docs recommendidentifierfor GRANT/DDL, and the referenceredshift-test.ymluses it.unquotedstrips every char outside[a-zA-Z0-9_], so a DB2 authorization ID containing a legal special char (e.g.#,$,@) would be silently rewritten and the grant applied to the wrong identifier. Both options are injection-safe;identifierjust avoids the silent corruption. (Confidence: medium)