mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FEATURE: Experimental support for group membership via google auth (#14835)
This commit introduces a new site setting "google_oauth2_hd_groups". If enabled, group information will be fetched from Google during authentication, and stored in the Discourse database. These 'associated groups' can be connected to a Discourse group via the "Membership" tab of the group preferences UI. The majority of the implementation is generic, so we will be able to add support to more authentication methods in the near future. https://meta.discourse.org/t/managing-group-membership-via-authentication/175950
This commit is contained in:
15
db/migrate/20211106085344_create_associated_groups.rb
Normal file
15
db/migrate/20211106085344_create_associated_groups.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateAssociatedGroups < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :associated_groups do |t|
|
||||
t.string :name, null: false
|
||||
t.string :provider_name, null: false
|
||||
t.string :provider_id, null: false
|
||||
t.datetime :last_used, null: false, default: -> { "CURRENT_TIMESTAMP" }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :associated_groups, %i[provider_name provider_id], unique: true, name: 'associated_groups_provider_id'
|
||||
end
|
||||
end
|
13
db/migrate/20211106085527_create_user_associated_groups.rb
Normal file
13
db/migrate/20211106085527_create_user_associated_groups.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateUserAssociatedGroups < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :user_associated_groups do |t|
|
||||
t.references :user, null: false
|
||||
t.references :associated_group, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :user_associated_groups, %i[user_id associated_group_id], unique: true, name: 'index_user_associated_groups'
|
||||
end
|
||||
end
|
13
db/migrate/20211106085605_create_group_associated_groups.rb
Normal file
13
db/migrate/20211106085605_create_group_associated_groups.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateGroupAssociatedGroups < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :group_associated_groups do |t|
|
||||
t.references :group, null: false
|
||||
t.references :associated_group, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :group_associated_groups, %i[group_id associated_group_id], unique: true, name: 'index_group_associated_groups'
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user