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 +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: f852d8c8fb4a6ab7e5afa05144de2fcc622ac073e7830fa4f4229d9975941d78
|
4
|
+
data.tar.gz: d8ad8fd69b33b1e952c363d9c149dba390f313b1168f0226678e78708efca5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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
|
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.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
|
+
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
|