keycloak_oauth 0.1.0 → 0.1.1
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +34 -0
- data/README.md +15 -1
- data/lib/keycloak_oauth.rb +19 -3
- data/lib/keycloak_oauth/configuration.rb +9 -0
- data/lib/keycloak_oauth/connection.rb +19 -0
- data/lib/keycloak_oauth/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6275c7d379287488ef1df79cde709790cbe5858bd34744471bda26287fe8f34
|
4
|
+
data.tar.gz: 354c76209bae9a13b6cb356b044265b3460c4c83d913b225aad814990aa9e080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4aef68f5760de30b1efdd98a5df1b57d1bfeaa79c4d09d1832002a65fac4dcd65910bd4bcac6af2b82dabb718991ae0797d8e08def30f4ed2400e3fc9ebb917
|
7
|
+
data.tar.gz: 1f0b961b0e5704a3b1fe3f1f838db547148671ba190e3dd3e8ad2a767678feb23219d7c20f6994eb70cda64987264b8d4028ce4ef66c843aadc3d828633c4569
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
keycloak_oauth (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.4.4)
|
10
|
+
rake (12.3.3)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.3)
|
16
|
+
rspec-support (~> 3.9.3)
|
17
|
+
rspec-expectations (3.9.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.3)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
keycloak_oauth!
|
30
|
+
rake (~> 12.0)
|
31
|
+
rspec (~> 3.0)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.4
|
data/README.md
CHANGED
@@ -22,7 +22,21 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
### Using `keycloak_oauth` in a Ruby on Rails app
|
26
|
+
|
27
|
+
The configuration must be defined in the app by initialising the relevant attributes within a configuration block. For example, you could add an initializer script called `keycloak_oauth.rb` holding the following code:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
KeycloakOauth.configure do |config|
|
31
|
+
config.auth_url = 'TBA' # (you could reference a Rails credential here for example)
|
32
|
+
config.realm = 'TBA'
|
33
|
+
config.client_id = 'TBA'
|
34
|
+
config.client_secret = 'TBA'
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
This then allows you to access the `KeycloakOauth` APIs:
|
39
|
+
`KeycloakOauth.connection.authorization_endpoint`
|
26
40
|
|
27
41
|
## Development
|
28
42
|
|
data/lib/keycloak_oauth.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'keycloak_oauth/version'
|
2
|
+
require 'keycloak_oauth/configuration'
|
3
|
+
require 'keycloak_oauth/connection'
|
2
4
|
|
3
5
|
module KeycloakOauth
|
4
|
-
|
5
|
-
|
6
|
+
def self.configure
|
7
|
+
yield(configuration) if block_given?
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configuration
|
11
|
+
Configuration.instance
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.connection
|
15
|
+
@connection ||= KeycloakOauth::Connection.new(
|
16
|
+
auth_url: configuration.auth_url,
|
17
|
+
realm: configuration.realm,
|
18
|
+
client_id: configuration.client_id,
|
19
|
+
client_secret: configuration.client_secret
|
20
|
+
)
|
21
|
+
end
|
6
22
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module KeycloakOauth
|
2
|
+
class Connection
|
3
|
+
attr_reader :auth_url, :realm, :client_id, :client_secret
|
4
|
+
|
5
|
+
DEFAULT_RESPONSE_TYPE = 'code'.freeze
|
6
|
+
|
7
|
+
def initialize(auth_url:, realm:, client_id:, client_secret:)
|
8
|
+
@auth_url = auth_url
|
9
|
+
@realm = realm
|
10
|
+
@client_id = client_id
|
11
|
+
@client_secret = client_secret
|
12
|
+
end
|
13
|
+
|
14
|
+
def authorization_endpoint(options: {})
|
15
|
+
endpoint = "#{auth_url}/realms/#{realm}/protocol/openid-connect/auth?client_id=#{client_id}"
|
16
|
+
endpoint += "&response_type=#{options[:response_type] || DEFAULT_RESPONSE_TYPE}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keycloak_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simplificator
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- ".rspec"
|
22
22
|
- CODE_OF_CONDUCT.md
|
23
23
|
- Gemfile
|
24
|
+
- Gemfile.lock
|
24
25
|
- LICENSE.txt
|
25
26
|
- README.md
|
26
27
|
- Rakefile
|
@@ -28,6 +29,8 @@ files:
|
|
28
29
|
- bin/setup
|
29
30
|
- keycloak_oauth.gemspec
|
30
31
|
- lib/keycloak_oauth.rb
|
32
|
+
- lib/keycloak_oauth/configuration.rb
|
33
|
+
- lib/keycloak_oauth/connection.rb
|
31
34
|
- lib/keycloak_oauth/version.rb
|
32
35
|
homepage: https://rubygems.org/gems/keycloak_oauth
|
33
36
|
licenses:
|