shakha 0.3.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Shakha
4
- class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path("templates", __dir__)
6
-
7
- class_option :skip_migration, type: :boolean, default: false, desc: "Skip migration generation"
8
-
9
- def copy_initializer
10
- template "initializer.rb.erb", "config/initializers/shakha.rb"
11
- end
12
-
13
- def create_migration
14
- return if options[:skip_migration]
15
-
16
- sleep 1
17
- migration_number = Time.now.strftime("%Y%m%d%H%M%S")
18
- template "migration.rb.erb", "db/migrate/#{migration_number}_create_shakha_tables.rb"
19
- end
20
-
21
- def add_routes
22
- route 'mount Shakha::Engine => "/auth/shakha", as: :shakha'
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Shakha Auth Configuration
4
- #
5
- # Set these environment variables:
6
- # SHAKHA_SERVICE_SECRET - Secret key for pairwise subject derivation (HMAC-SHA256)
7
- # GOOGLE_CLIENT_ID - Google OAuth client ID
8
- # GOOGLE_CLIENT_SECRET - Google OAuth client secret
9
- # SHAKHA_APP_ORIGIN - Your application's origin (e.g., http://localhost:3000)
10
- # SHAKHA_SERVICE_URL - Optional: URL of standalone Shakha service (omit for embedded mode)
11
- #
12
- # For ES256 JWT signing, set either:
13
- # SHAKHA_SIGNING_KEY - EC P-256 private key in PEM or base64 format
14
- # SHAKHA_KEY_ID - Key ID for JWKS (optional, defaults to "default")
15
-
16
- Shakha.setup do |config|
17
- config.app_origin = ENV.fetch("SHAKHA_APP_ORIGIN", "http://localhost:3000")
18
- config.service_url = ENV["SHAKHA_SERVICE_URL"]
19
- config.service_secret = ENV["SHAKHA_SERVICE_SECRET"]
20
- config.google_client_id = ENV["GOOGLE_CLIENT_ID"]
21
- config.google_client_secret = ENV["GOOGLE_CLIENT_SECRET"]
22
- config.issuer = ENV.fetch("SHAKHA_ISSUER", "https://shakha.dev")
23
- config.session_lifetime = 30.days
24
-
25
- # JWT signing keys (required for service mode)
26
- config.signing_key = ENV["SHAKHA_SIGNING_KEY"]
27
- config.verification_key = ENV["SHAKHA_VERIFICATION_KEY"]
28
- config.key_id = ENV["SHAKHA_KEY_ID"] || "default"
29
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateShakhaTables < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :shakha_clients do |t|
6
- t.string :name, null: false
7
- t.string :origin, null: false
8
- t.string :client_id
9
- t.json :metadata, default: {}
10
-
11
- t.timestamps
12
- end
13
-
14
- add_index :shakha_clients, :origin, unique: true
15
- add_index :shakha_clients, :client_id, unique: true
16
-
17
- create_table :shakha_users do |t|
18
- t.string :pairwise_sub, null: false
19
- t.string :email
20
- t.string :name
21
- t.string :picture
22
- t.references :client, null: false
23
-
24
- t.timestamps
25
- end
26
-
27
- add_index :shakha_users, :pairwise_sub, unique: true
28
- add_index :shakha_users, :email
29
-
30
- create_table :shakha_sessions do |t|
31
- t.string :token, null: false
32
- t.string :jti, null: false
33
- t.references :user, null: false
34
- t.references :client, null: false
35
- t.string :ip_address
36
- t.string :user_agent
37
-
38
- t.timestamps
39
- end
40
-
41
- add_index :shakha_sessions, :token, unique: true
42
- add_index :shakha_sessions, :jti, unique: true
43
- add_index :shakha_sessions, :created_at
44
- end
45
- end