external_identity 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac62f20595ca3f477a16c151b0bbd428501e4bb0fa766db6359c95981bacbc07
4
+ data.tar.gz: fbb9c9d00d8abbc70a8a4cc4afe07f1e8e91ae289c51e7c413fccf19db443cff
5
+ SHA512:
6
+ metadata.gz: d1fa99e350a0cda6235023b6062ba9a3bf7e11a007ca12f22287854657b7a0523a3c146f11628e12b940453800d59ec3d0b2f9ccf10f05fdb8208ca7b9e29724
7
+ data.tar.gz: 2190bdb5e3c5e0145b260537a1cafd5850c9509a6b9a0a70fbd235abe37e6586a5e5901e3cefa61626d94f987cf4c0751d26093840c763235042e0560febbbdd
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ external_identity
2
+ -------------
3
+ [![RSpec](https://github.com/kjellberg/external_identity/actions/workflows/rspec.yaml/badge.svg)](https://github.com/kjellberg/external_identity/actions/workflows/rspec.yaml)
4
+ [![RuboCop](https://github.com/kjellberg/external_identity/actions/workflows/rubocop.yaml/badge.svg)](https://github.com/kjellberg/external_identity/actions/workflows/rubocop.yaml)
5
+
6
+ **external_identity** validates incoming authentication tokens (for example [jwt](https://datatracker.ietf.org/doc/html/rfc7519)) from external identity management services like [Auth0](https://auth0.com/) and [Firebase](https://firebase.google.com/docs/auth). It runs as a **Rack middleware** which means that it works seamlessly with Rails, Grape, Sinatra and other Rack based applications.
7
+
8
+ ## Installation
9
+
10
+ Add the following line to Gemfile:
11
+
12
+ ```ruby
13
+ gem "external_identity", github: "kiqr/external_identity" # Use development branch until first release.
14
+ ```
15
+
16
+ and run `bundle install` from your terminal to install it.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalIdentity
4
+ class Identity
5
+ # @param [String] id
6
+ attr_accessor :id
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalIdentity
4
+ class Manager
5
+ attr_accessor :env
6
+
7
+ def initialize(env)
8
+ @env = env
9
+ end
10
+
11
+ def authenticate!
12
+ warden.authenticate!(scope: warden_scope)
13
+ end
14
+
15
+ def identity
16
+ @identity ||= warden.authenticate(scope: warden_scope)
17
+ end
18
+
19
+ def valid?
20
+ !!identity
21
+ end
22
+
23
+ private
24
+
25
+ def warden
26
+ env['warden']
27
+ end
28
+
29
+ def warden_scope
30
+ ExternalIdentity.config.warden.scope || :external_identity
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalIdentity
4
+ class Middleware
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ # Setup the global accessable Rack env variable.
11
+ env['external_identity'] = ExternalIdentity::Manager.new(env)
12
+
13
+ # Wrap our app around Warden::Manager to make sure it's loaded already.
14
+ app_with_warden = Warden::Manager.new(@app)
15
+
16
+ # Call the app with our modified env.
17
+ app_with_warden.call(env)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalIdentity
4
+ VERSION = '0.0.0'
5
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'external_identity/version'
4
+
5
+ require 'dry-configurable'
6
+ require 'rack'
7
+ require 'warden'
8
+
9
+ module ExternalIdentity
10
+ extend Dry::Configurable
11
+
12
+ autoload :Manager, 'external_identity/manager'
13
+ autoload :Middleware, 'external_identity/middleware'
14
+ autoload :Identity, 'external_identity/identity'
15
+
16
+ setting :warden do
17
+ setting :scope, default: :external_identity
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: external_identity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - KIQR
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-configurable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: warden
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.9
41
+ description:
42
+ email: hello@kiqr.dev
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - README.md
48
+ - lib/external_identity.rb
49
+ - lib/external_identity/identity.rb
50
+ - lib/external_identity/manager.rb
51
+ - lib/external_identity/middleware.rb
52
+ - lib/external_identity/version.rb
53
+ homepage: https://github.com/kiqr/external_identity
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ bug_tracker_uri: https://github.com/kiqr/external_identity/issues
58
+ documentation_uri: https://github.com/kiqr/external_identity/issues
59
+ source_code_uri: https://github.com/kiqr/external_identity
60
+ rubygems_mfa_required: 'true'
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.6.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.3.13
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Authentication solution for Ruby on Rails
80
+ test_files: []