More complete oidc
This commit is contained in:
22
db/migrate/20251112114852_create_oidc_refresh_tokens.rb
Normal file
22
db/migrate/20251112114852_create_oidc_refresh_tokens.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class CreateOidcRefreshTokens < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :oidc_refresh_tokens do |t|
|
||||
t.string :token_digest, null: false # BCrypt hashed token
|
||||
t.references :application, null: false, foreign_key: true
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.references :oidc_access_token, null: false, foreign_key: true
|
||||
t.string :scope
|
||||
t.datetime :expires_at, null: false
|
||||
t.datetime :revoked_at
|
||||
t.integer :token_family_id # For token rotation detection
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :oidc_refresh_tokens, :token_digest, unique: true
|
||||
add_index :oidc_refresh_tokens, :expires_at
|
||||
add_index :oidc_refresh_tokens, :revoked_at
|
||||
add_index :oidc_refresh_tokens, :token_family_id
|
||||
add_index :oidc_refresh_tokens, [ :application_id, :user_id ]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddTokenDigestToOidcAccessTokens < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_column :oidc_access_tokens, :token_digest, :string
|
||||
add_column :oidc_access_tokens, :revoked_at, :datetime
|
||||
|
||||
add_index :oidc_access_tokens, :token_digest, unique: true
|
||||
add_index :oidc_access_tokens, :revoked_at
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddTokenExpiryToApplications < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_column :applications, :access_token_ttl, :integer, default: 3600 # 1 hour in seconds
|
||||
add_column :applications, :refresh_token_ttl, :integer, default: 2592000 # 30 days in seconds
|
||||
add_column :applications, :id_token_ttl, :integer, default: 3600 # 1 hour in seconds
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class MakeOidcAccessTokenTokenNullable < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
change_column_null :oidc_access_tokens, :token, true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user