minato-rails-auth 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9c9ae3638648d8a758dc1b651d29889d03a750d7976923c9e2cd0abfe8f31d5
4
- data.tar.gz: 7e70a4134521be3283aa9b4d7b55c13fa641e521ffcfd983539d35860d97d777
3
+ metadata.gz: d8604698708e566c6bafcdfb266913b0e2aacbdabb44451212cfab2af34f2583
4
+ data.tar.gz: 5a08d876eee74aa03c58dea4893e2dab2d15abe9c4392440a3a6f9ccb2a4ff2d
5
5
  SHA512:
6
- metadata.gz: 50c308ceff9be12a49e6ce924e86aca424bf6169f85b4d553827aaebca64e4474a9c41c7649098eca041f6a90c2ac691a9e761aedf96b453a5839da8b3d6811a
7
- data.tar.gz: 0443ab1086d699acad7de5fb4c1252af3d593ed2032121672f64848616570071222bd7c33a4de6b79f3fca5eff4eb70ac212778fd2649933855efad7067f23a5
6
+ metadata.gz: 37c6f45719975a70f7fc2ba11b2605d6764d080126281d6cf88d212c575d05f041ed8e41c29ab93045ca9b992711f4c22084795f6ddadabb4b25e4fc21b39f60
7
+ data.tar.gz: e36d6abdc74a8e3ec50aace97f9840fbf5210080ed97fffc0dde44f6cf7cc1c397ad89cee7b30dbd19117683eb4739cfe8038f360b4249aca437c8345b078dad
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "${localWorkspaceFolderBasename}",
3
+ "dockerComposeFile": [
4
+ "../compose.yml",
5
+ "docker-compose.yml"
6
+ ],
7
+ "service": "minato-rails-auth",
8
+ "workspaceFolder": "/usr/src/api",
9
+ "features": {
10
+ "ghcr.io/devcontainers/features/common-utils:2": {},
11
+ "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
12
+ "plugins": "zsh-autosuggestions zsh-syntax-highlighting",
13
+ "omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-syntax-highlighting"
14
+ },
15
+ "ghcr.io/guiyomh/features/vim:0": {},
16
+ "ghcr.io/devcontainers/features/git:1.1.0": {}
17
+ },
18
+ "customizations": {
19
+ "vscode": {
20
+ "extensions": [
21
+ "eamodio.gitlens",
22
+ "redhat.vscode-yaml",
23
+ "EditorConfig.EditorConfig",
24
+ "GitLab.gitlab-workflow",
25
+ "MS-vsliveshare.vsliveshare"
26
+ ],
27
+ "settings": {
28
+ "terminal.integrated.defaultProfile.linux": "zsh",
29
+ "terminal.integrated.defaultProfile.windows": "zsh",
30
+ "terminal.integrated.defaultProfile.osx": "zsh"
31
+ }
32
+ }
33
+ },
34
+ "postCreateCommand": "bundle config --local GITLAB__COM gitlab-ci-token:$GITLAB_AUTH_TOKEN",
35
+ "postStartCommand": "bundle install",
36
+ "remoteUser": "ruby"
37
+ }
@@ -0,0 +1,8 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ minato-rails-auth:
5
+ volumes:
6
+ - .:/usr/src/api:cached
7
+ entrypoint: []
8
+ command: /bin/sh -c "while sleep 1000; do :; done"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'user'
3
+ require 'minato/rails/auth/user'
4
4
  require 'active_support'
5
5
 
6
6
  module Minato
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'jwt/user'
3
+ require_relative 'user'
4
4
  require_relative 'configuration'
5
5
  require_relative 'jwt/decode'
6
6
  require 'active_support'
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'object_hash'
4
+
5
+ module Minato
6
+ module Rails
7
+ module Auth
8
+ class User
9
+ attr_reader :token_payload
10
+
11
+ def initialize(token_payload)
12
+ @token_payload = ObjectHash.new(token_payload)
13
+ end
14
+
15
+ def human?
16
+ @human ||= @token_payload.respond_to?(:session)
17
+ end
18
+
19
+ def machine?
20
+ @machine ||= !human?
21
+ end
22
+
23
+ def identity_id
24
+ return session.identity.id unless impersonated?
25
+
26
+ session.identity.metadata_public.impersonated_identity_id
27
+ end
28
+
29
+ def impersonator_identity_id
30
+ session.identity.id
31
+ end
32
+
33
+ def subject
34
+ @token_payload.sub
35
+ end
36
+
37
+ def impersonated?
38
+ !session.identity.metadata_public&.impersonated_identity_id.nil?
39
+ end
40
+
41
+ private
42
+
43
+ def session
44
+ @token_payload.session
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -3,7 +3,7 @@
3
3
  module Minato
4
4
  module Rails
5
5
  module Auth
6
- VERSION = '0.1.1'
6
+ VERSION = '0.2.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minato-rails-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferreri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -45,6 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".devcontainer/devcontainer.json"
49
+ - ".devcontainer/docker-compose.yml"
48
50
  - ".rspec"
49
51
  - ".rubocop.yml"
50
52
  - README.md
@@ -56,8 +58,8 @@ files:
56
58
  - lib/minato/rails/auth/jwt/configuration.rb
57
59
  - lib/minato/rails/auth/jwt/decode.rb
58
60
  - lib/minato/rails/auth/jwt/spec/contexts.rb
59
- - lib/minato/rails/auth/jwt/user.rb
60
61
  - lib/minato/rails/auth/spec.rb
62
+ - lib/minato/rails/auth/user.rb
61
63
  - lib/minato/rails/auth/version.rb
62
64
  - lib/object_hash.rb
63
65
  - minato-rails-auth.gemspec
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'object_hash'
4
-
5
- module Minato
6
- module Rails
7
- module Auth
8
- module JWT
9
- class User
10
- attr_reader :token_payload
11
-
12
- def initialize(token_payload)
13
- @token_payload = ObjectHash.new(token_payload)
14
- end
15
-
16
- def human?
17
- @human ||= @token_payload.respond_to?(:session)
18
- end
19
-
20
- def machine?
21
- @machine ||= !human?
22
- end
23
-
24
- def session
25
- @token_payload.session
26
- end
27
-
28
- def subject
29
- @token_payload.sub
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end