Module: KindeSdk::Client::Permissions
- Included in:
- KindeSdk::Client
- Defined in:
- lib/kinde_sdk/client/permissions.rb
Instance Method Summary collapse
-
#get_permission(permission, options = {}) ⇒ Hash
Get a specific permission status.
-
#get_permissions(options = {}) ⇒ Hash
Get all permissions for the authenticated user Matches the JavaScript SDK API: getPermissions(options?).
-
#get_permissions_legacy(token_type = :access_token) ⇒ Object
Backward compatibility method - matches existing Ruby SDK API.
-
#getAllPermissions ⇒ Array
(also: #all_permissions)
Get all permissions with automatic pagination (hard check) Matches PHP: $client->getAllPermissions().
-
#getPermissions ⇒ Hash
PHP SDK compatible alias for get_permissions with hard check Matches PHP: $client->getPermissions().
-
#permission_granted?(permission, options = {}) ⇒ Boolean
Check if a permission is granted.
Instance Method Details
#get_permission(permission, options = {}) ⇒ Hash
Get a specific permission status
48 49 50 51 52 53 54 55 |
# File 'lib/kinde_sdk/client/permissions.rb', line 48 def (, = {}) = () { org_code: [:org_code], is_granted: [:permissions]&.include?() || false } end |
#get_permissions(options = {}) ⇒ Hash
Get all permissions for the authenticated user Matches the JavaScript SDK API: getPermissions(options?)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kinde_sdk/client/permissions.rb', line 24 def ( = {}) # Handle legacy positional argument for backward compatibility if .is_a?(Symbol) = { token_type: } end # Extract options with defaults - use member variable if not overridden force_api = [:force_api] || @force_api || false token_type = [:token_type] || :access_token if force_api # Hard check - call API for fresh permissions else # Soft check - extract from token claims (token_type) end end |
#get_permissions_legacy(token_type = :access_token) ⇒ Object
Backward compatibility method - matches existing Ruby SDK API
91 92 93 |
# File 'lib/kinde_sdk/client/permissions.rb', line 91 def (token_type = :access_token) get_claim("permissions", token_type)&.dig(:value) end |
#getAllPermissions ⇒ Array Also known as: all_permissions
Get all permissions with automatic pagination (hard check) Matches PHP: $client->getAllPermissions()
80 81 82 83 84 85 |
# File 'lib/kinde_sdk/client/permissions.rb', line 80 def getAllPermissions # Use client's force_api setting, default to true for PHP SDK compatibility force_api_setting = @force_api.nil? ? true : @force_api = (force_api: force_api_setting) [:permissions] || [] end |
#getPermissions ⇒ Hash
PHP SDK compatible alias for get_permissions with hard check Matches PHP: $client->getPermissions()
70 71 72 73 74 |
# File 'lib/kinde_sdk/client/permissions.rb', line 70 def getPermissions # Use client's force_api setting, default to true for PHP SDK compatibility force_api_setting = @force_api.nil? ? true : @force_api (force_api: force_api_setting) end |
#permission_granted?(permission, options = {}) ⇒ Boolean
Check if a permission is granted
62 63 64 |
# File 'lib/kinde_sdk/client/permissions.rb', line 62 def (, = {}) (, )[:is_granted] end |