code0-identities 0.0.3 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5454fae02745bc707943c9ec6e68f6c9f62fd0009c78a3dabc5a7b232eae6af
4
- data.tar.gz: d0fb4d77ec213dc693073ba5ce9e7cba591907fed450cde5cf6d109a8edc9552
3
+ metadata.gz: c3e5724102623eaf362b5b7e1ba27c651e407bc60d4372565c1fd951c09fe6b4
4
+ data.tar.gz: c66360aa1994f99bf10e2c1026fe28f1a4d3334bbf9e65d9c9c1558c0497250c
5
5
  SHA512:
6
- metadata.gz: e07dad5a27f08b2df35eae0c5474c8c1595e8195b8cc5d156a6f104971991ec636ac7adb827c03be2e454f0d13907da0e6761413eb4dda09dca828e2a958dd2c
7
- data.tar.gz: '08c3f69cc47df910b84a08fad74916827be3213e3c0813858b96747bd01c324aa77b5af1cef786c5937c77afd86f2b85e9dd694cf8a5453323a420fedcfc9cf4'
6
+ metadata.gz: a500b3e176dedbdfa5f1d8f4a977e3fe216efc7ca0d7f59dc400f49734b3054bf306931b3d15f155453179714d70a3483b2a03f0e80b96a82967bea72ab0056f
7
+ data.tar.gz: 7dfde832c6e491088f798b59c4b9a1e0ad10478662a063787a925a9bf924440369aec16963e64842a486f1f809c6c2c98af994be299e5bf3c104c78847f2eeb0
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2023-2026 Code0 UG (haftungsbeschränkt)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ AI Usage Restriction: Notwithstanding the permissions granted above, this Software and its source code may not be used, in whole or in part, for the purpose of training, fine-tuning, or developing artificial intelligence (AI) models or machine learning algorithms without prior written consent from the Copyright Holder.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -24,7 +24,11 @@ module Code0
24
24
  raise Error, "Provider with id '#{provider_id}' is not configured, did you forget to use add_provider"
25
25
  end
26
26
 
27
- provider.load_identity(params)
27
+ provider.load_identity(**params)
28
+ end
29
+
30
+ def self.for_type(provider_type)
31
+ Identities::Provider.const_get(provider_type.capitalize)
28
32
  end
29
33
  end
30
34
  end
@@ -10,6 +10,10 @@ module Code0
10
10
  @config_loader = config_loader
11
11
  end
12
12
 
13
+ def validate_config!
14
+ raise NotImplementedError
15
+ end
16
+
13
17
  def authorization_url
14
18
  raise NotImplementedError
15
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Discord < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[redirect_uri client_id client_secret]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def token_url
8
18
  "https://discord.com/api/oauth2/token"
9
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Github < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[redirect_uri client_id client_secret]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def token_url
8
18
  "https://github.com/login/oauth/access_token"
9
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Gitlab < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[base_url redirect_uri client_id client_secret]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def base_url
8
18
  config[:base_url]
9
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Google < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[redirect_uri client_id client_secret]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def base_url
8
18
  "https://accounts.google.com"
9
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Microsoft < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[redirect_uri client_id client_secret]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def base_url
8
18
  "https://graph.microsoft.com/"
9
19
  end
@@ -4,6 +4,16 @@ module Code0
4
4
  module Identities
5
5
  module Provider
6
6
  class Oidc < BaseOauth
7
+ def validate_config!
8
+ required_keys = %i[client_id client_secret redirect_uri token_url user_details_url authorization_url]
9
+
10
+ missing_keys = required_keys - config.keys
11
+ invalid_keys = config.keys - required_keys - [:provider_name]
12
+
13
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
14
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
15
+ end
16
+
7
17
  def token_url
8
18
  config[:token_url]
9
19
  end
@@ -10,6 +10,16 @@ module Code0
10
10
  @config_loader = config_loader
11
11
  end
12
12
 
13
+ def validate_config!
14
+ required_keys = config[:metadata_url].nil? ? %i[settings] : %i[metadata_url]
15
+
16
+ missing_keys = required_keys - config.keys
17
+ invalid_keys = config.keys - %i[provider_name metadata_url settings response_settings attribute_statements]
18
+
19
+ raise MissingConfigurationError, "Missing: #{missing_keys.inspect}" if missing_keys.any?
20
+ raise InvalidConfigurationError, "Invalid: #{invalid_keys.inspect}" if invalid_keys.any?
21
+ end
22
+
13
23
  def authorization_url
14
24
  request = OneLogin::RubySaml::Authrequest.new
15
25
  request.create(create_settings)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Code0
4
4
  module Identities
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
@@ -18,5 +18,7 @@ require_relative "identities/provider/saml"
18
18
  module Code0
19
19
  module Identities
20
20
  class Error < StandardError; end
21
+ class MissingConfigurationError < Error; end
22
+ class InvalidConfigurationError < Error; end
21
23
  end
22
24
  end
@@ -3,6 +3,8 @@
3
3
  module Code0
4
4
  module Identities
5
5
  class IdentityProvider
6
+ def self.for_type: -> Class
7
+
6
8
  attr_reader providers: Hash[Symbol, Provider::BaseOauth]
7
9
 
8
10
  def initialize: () -> void
@@ -8,6 +8,8 @@ module Code0
8
8
 
9
9
  def authorization_url: () -> String
10
10
 
11
+ def validate_config!: -> void
12
+
11
13
  def token_url: () -> String
12
14
 
13
15
  def user_details_url: () -> String
@@ -4,6 +4,8 @@ module Code0
4
4
  class Saml
5
5
  def authorization_url: () -> String
6
6
 
7
+ def validate_config!: -> void
8
+
7
9
  def load_identity: (Hash[Symbol, any]) -> Identity
8
10
  end
9
11
  end
@@ -1,5 +1,7 @@
1
1
  module Code0
2
2
  module Identities
3
3
  class Error < StandardError end
4
+ class MissingConfigurationError < Error end
5
+ class InvalidConfigurationError < Error end
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code0-identities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dario Pranjic
@@ -144,7 +144,7 @@ files:
144
144
  - ".rspec"
145
145
  - ".rubocop.yml"
146
146
  - ".tool-versions"
147
- - LICENSE.txt
147
+ - LICENSE
148
148
  - README.md
149
149
  - Rakefile
150
150
  - lib/code0/identities.rb
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 TODO: Write your name
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.