minato-rails-auth 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9c9ae3638648d8a758dc1b651d29889d03a750d7976923c9e2cd0abfe8f31d5
4
- data.tar.gz: 7e70a4134521be3283aa9b4d7b55c13fa641e521ffcfd983539d35860d97d777
3
+ metadata.gz: f852d8c8fb4a6ab7e5afa05144de2fcc622ac073e7830fa4f4229d9975941d78
4
+ data.tar.gz: d8ad8fd69b33b1e952c363d9c149dba390f313b1168f0226678e78708efca5b3
5
5
  SHA512:
6
- metadata.gz: 50c308ceff9be12a49e6ce924e86aca424bf6169f85b4d553827aaebca64e4474a9c41c7649098eca041f6a90c2ac691a9e761aedf96b453a5839da8b3d6811a
7
- data.tar.gz: 0443ab1086d699acad7de5fb4c1252af3d593ed2032121672f64848616570071222bd7c33a4de6b79f3fca5eff4eb70ac212778fd2649933855efad7067f23a5
6
+ metadata.gz: 19744e2044ad31a4754435d0df1ab7cdff2233ce5ce8f36ad971ec0dc08544ca3506297ec04e55f5f50f0e5943e19f2bbd12b93633e42e586c34e336e6ff4959
7
+ data.tar.gz: bcbfdec2e4b3b57c914e326e44d7e24490959d356bf838aca0a3a0a764880ba89b7982abe0edce4024502c75118a7bb53d82089628091d5ba7c73d3284e552bb
@@ -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
24
+ return impersonator_identity unless impersonated?
25
+
26
+ session.identity.metadata_public.impersonated_identity
27
+ end
28
+
29
+ def impersonator_identity
30
+ session.identity
31
+ end
32
+
33
+ def subject
34
+ @token_payload.sub
35
+ end
36
+
37
+ def impersonated?
38
+ session.identity.metadata_public&.impersonated_identity.present?
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.1'
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.1
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-30 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