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 +4 -4
- data/.devcontainer/devcontainer.json +37 -0
- data/.devcontainer/docker-compose.yml +8 -0
- data/lib/minato/rails/auth/jwt/configuration.rb +1 -1
- data/lib/minato/rails/auth/jwt.rb +1 -1
- data/lib/minato/rails/auth/user.rb +49 -0
- data/lib/minato/rails/auth/version.rb +1 -1
- metadata +5 -3
- data/lib/minato/rails/auth/jwt/user.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8604698708e566c6bafcdfb266913b0e2aacbdabb44451212cfab2af34f2583
|
4
|
+
data.tar.gz: 5a08d876eee74aa03c58dea4893e2dab2d15abe9c4392440a3a6f9ccb2a4ff2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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
|
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.
|
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
|
+
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
|