Skip to content

Add Microsoft integration tables and models

Drew Blessing requested to merge dblessing_azure_group_sync_settings into master

What does this MR do and why?

Related to #414874 (closed)

This adds two new tables and associated models so we can integrate with Microsoft Graph API.

We will only ever have one Access Token at a time. Each token lasts for 60 minutes. Once a token expires, the tenant ID, client ID and secret can be used to obtain a new one.

In a subsequent MR we will add settings to the SAML SSO settings page in the top-level group so Group Owners can configure the Application tenant ID, client ID and secret, as well as enable/disable the integration.

Then we will use these values in other issues associated with this epic - &10507.

Database

Migrate

main: == [advisory_lock_connection] object_id: 228820, pg_backend_pid: 95339
main: == 20230616200440 CreateSystemAccessMicrosoftApplication: migrating ===========
main: -- create_table(:system_access_microsoft_applications)
main: -- quote_column_name(:tenant_xid)
main:    -> 0.0000s
main: -- quote_column_name(:client_xid)
main:    -> 0.0000s
main:    -> 0.0127s
main: -- quote_column_name(:login_endpoint)
main:    -> 0.0000s
main: -- quote_column_name(:graph_endpoint)
main:    -> 0.0000s
main:    -> 0.0173s
main: == 20230616200440 CreateSystemAccessMicrosoftApplication: migrated (0.1447s) ==

main: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: migrating =====
main: -- create_table(:system_access_microsoft_graph_access_tokens)
main:    -> 0.0037s
main: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: migrated (0.0067s)

main: == [advisory_lock_connection] object_id: 228820, pg_backend_pid: 95339
ci: == [advisory_lock_connection] object_id: 229100, pg_backend_pid: 95341
ci: == 20230616200440 CreateSystemAccessMicrosoftApplication: migrating ===========
ci: -- create_table(:system_access_microsoft_applications)
ci: -- quote_column_name(:tenant_xid)
ci:    -> 0.0000s
ci: -- quote_column_name(:client_xid)
ci:    -> 0.0000s
ci:    -> 0.0115s
ci: -- quote_column_name(:login_endpoint)
ci:    -> 0.0000s
ci: -- quote_column_name(:graph_endpoint)
ci:    -> 0.0000s
ci:    -> 0.0173s
I, [2023-06-20T13:11:06.467488 #95166]  INFO -- : Database: 'ci', Table: 'system_access_microsoft_applications': Lock Writes
ci: == 20230616200440 CreateSystemAccessMicrosoftApplication: migrated (0.0223s) ==

ci: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: migrating =====
ci: -- create_table(:system_access_microsoft_graph_access_tokens)
ci:    -> 0.0030s
I, [2023-06-20T13:11:06.481060 #95166]  INFO -- : Database: 'ci', Table: 'system_access_microsoft_graph_access_tokens': Lock Writes
ci: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: migrated (0.0114s)

ci: == [advisory_lock_connection] object_id: 229100, pg_backend_pid: 95341

Rollback

main: == [advisory_lock_connection] object_id: 228620, pg_backend_pid: 93557
main: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: reverting =====
main: -- drop_table(:system_access_microsoft_graph_access_tokens)
main:    -> 0.0065s
main: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: reverted (0.0128s)

main: == [advisory_lock_connection] object_id: 228620, pg_backend_pid: 93557

main: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94435
main: == 20230616200440 CreateSystemAccessMicrosoftApplication: reverting ===========
main: -- drop_table(:system_access_microsoft_applications)
main:    -> 0.0030s
main: == 20230616200440 CreateSystemAccessMicrosoftApplication: reverted (0.0083s) ==

main: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94435

ci: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94006
ci: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: reverting =====
ci: -- drop_table(:system_access_microsoft_graph_access_tokens)
ci:    -> 0.0032s
ci: == 20230616214220 CreateSystemAccessMicrosoftGraphAccessTokens: reverted (0.0130s)

ci: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94006

ci: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94866
ci: == 20230616200440 CreateSystemAccessMicrosoftApplication: reverting ===========
ci: -- drop_table(:system_access_microsoft_applications)
ci:    -> 0.0034s
ci: == 20230616200440 CreateSystemAccessMicrosoftApplication: reverted (0.0144s) ==

ci: == [advisory_lock_connection] object_id: 228520, pg_backend_pid: 94866

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Drew Blessing

Merge request reports