virgil-jwt 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +33 -0
- data/README.md +203 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/virgil-sdk-ruby-jwt +3 -0
- data/lib/virgil/jwt.rb +14 -0
- data/lib/virgil/jwt/access_token.rb +51 -0
- data/lib/virgil/jwt/access_token_provider.rb +46 -0
- data/lib/virgil/jwt/bytes.rb +125 -0
- data/lib/virgil/jwt/caching_jwt_provider.rb +74 -0
- data/lib/virgil/jwt/callback_jwt_provider.rb +60 -0
- data/lib/virgil/jwt/const_access_token_provider.rb +56 -0
- data/lib/virgil/jwt/jwt.rb +132 -0
- data/lib/virgil/jwt/jwt_body_content.rb +110 -0
- data/lib/virgil/jwt/jwt_generator.rb +110 -0
- data/lib/virgil/jwt/jwt_header_content.rb +94 -0
- data/lib/virgil/jwt/jwt_verifier.rb +78 -0
- data/lib/virgil/jwt/token_context.rb +72 -0
- data/lib/virgil/jwt/validation.rb +59 -0
- data/lib/virgil/jwt/version.rb +5 -0
- data/virgil-jwt.gemspec +31 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd658cbf3a3f60af8caef3f1cbbc87f4ff654bd34c10867d5dbe5d047b58a958
|
4
|
+
data.tar.gz: cd0faee77bbc05e9fdac6f790db75b470a5c089e3169ef71e8f1266c681e0452
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59cd27fb3338bc5b9860444abad60af31de2b85719902d00f7d80f43953609347ebca2068041b75ffa9aa7ab101b7d999d969cc65a7aef7abc1dd81db0fb7e73
|
7
|
+
data.tar.gz: 6cb5bd2c18e6a60ab2de063b3abab9ced403f61f52fdf0d6e05cc56a12181e27221dbaba55697f406fdb0714b2da645407b2a9c70e027688df4d9faf131476cc
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
virgil-jwt (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
builder (3.2.3)
|
11
|
+
envyable (1.2.0)
|
12
|
+
thor (>= 0.18.1, < 2.0)
|
13
|
+
minitest (5.10.3)
|
14
|
+
minitest-reporters (1.3.6)
|
15
|
+
ansi
|
16
|
+
builder
|
17
|
+
minitest (>= 5.0)
|
18
|
+
ruby-progressbar
|
19
|
+
rake (10.5.0)
|
20
|
+
ruby-progressbar (1.10.0)
|
21
|
+
thor (0.20.0)
|
22
|
+
virgil-crypto (3.6.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (~> 1.16)
|
29
|
+
envyable (~> 1.2)
|
30
|
+
minitest (~> 5.0)
|
31
|
+
minitest-reporters (~> 1.1)
|
32
|
+
rake (~> 10.0)
|
33
|
+
virgil-crypto (~> 3.6, >= 3.6.2)
|
34
|
+
virgil-jwt!
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
1.16.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (C) 2015-2019 Virgil Security Inc.
|
2
|
+
#
|
3
|
+
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
4
|
+
#
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in
|
16
|
+
# the documentation and/or other materials provided with the
|
17
|
+
# distribution.
|
18
|
+
#
|
19
|
+
# (3) Neither the name of the copyright holder nor the names of its
|
20
|
+
# contributors may be used to endorse or promote products derived from
|
21
|
+
# this software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
24
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
27
|
+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
+
# SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
|
+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
31
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
32
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
# Virgil JWT
|
2
|
+
[![Gem](https://img.shields.io/gem/v/virgil-jwt.svg)](https://rubygems.org/gems/virgil-jwt)
|
3
|
+
[![GitHub license](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg)](https://github.com/VirgilSecurity/virgil/blob/master/LICENSE)
|
4
|
+
|
5
|
+
### [Introduction](#introduction) | [Library purposes](#library-purposes) | [Usage examples](#usage-examples) | [Installation](#installation) | [Docs](#docs) | [License](#license) | [Contacts](#support)
|
6
|
+
|
7
|
+
## Introduction
|
8
|
+
Virgil JSON Web Token ("JWT") allows you to make call to Virgil Services without having to know how they're constructed.
|
9
|
+
## Library purposes
|
10
|
+
* Authentication using tokens that are based on the [JSON Web Token standard](https://jwt.io) but with some Virgil modification.
|
11
|
+
|
12
|
+
## Usage examples
|
13
|
+
|
14
|
+
#### Virgil developer credentials
|
15
|
+
|
16
|
+
Collect your Virgil developer credentials form [Virgil Dashboard](https://dashboard.virgilsecurity.com):
|
17
|
+
APP_ID, API_KEY_ID, API_KEY
|
18
|
+
|
19
|
+
| Parameter |Description |
|
20
|
+
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
21
|
+
| APP_ID | ID of your Application at [Virgil Dashboard](https://dashboard.virgilsecurity.com) |
|
22
|
+
| API_KEY_ID | A unique string value that identifies your account at the Virgil developer portal |
|
23
|
+
| API_KEY | A Private Key that is used to sign API calls to Virgil Services. For security, you will only be shown the API Private Key when the key is created. Don't forget to save it in a secure location for the next step |
|
24
|
+
|
25
|
+
Generate a Private Key with the default algorithm (EC_X25519):
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'virgil/crypto'
|
29
|
+
include Virgil::Crypto
|
30
|
+
|
31
|
+
crypto = VirgilCrypto.new
|
32
|
+
key_pair = crypto.generate_keys
|
33
|
+
```
|
34
|
+
|
35
|
+
### Set up Client side and send a JWT request
|
36
|
+
After a user installs Virgil Jwt you'll need to set up JWT Provider for providing a user with a JWT. You'll need to give your users a JWT that tells Virgil who they are and what they can do.
|
37
|
+
Requests to your app server must be authorized. You can use any kind of authentication, for example, Google auth.
|
38
|
+
|
39
|
+
#### Set up JWT provider
|
40
|
+
Use these lines of code to specify which JWT generation source you prefer to use in your project:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require 'virgil/crypto'
|
44
|
+
require 'virgil/jwt'
|
45
|
+
include Virgil::Crypto
|
46
|
+
include Virgil::Jwt
|
47
|
+
|
48
|
+
# Get generated token from server-side
|
49
|
+
obtain_token_proc = proc { authenticated_query_to_server('my_token_identity').to_s }
|
50
|
+
|
51
|
+
# Setup AccessTokenProvider
|
52
|
+
access_token_provider = CallbackJwtProvider(obtain_token_proc)
|
53
|
+
```
|
54
|
+
|
55
|
+
### Set up Server Side and Generate JWT
|
56
|
+
|
57
|
+
Next, you'll set up the JwtGenerator and generate a JWT using the Virgil SDK.
|
58
|
+
You'll use your API Key that was created at Virgil Dashboard. For security purposes, you have to generate JWT on your server side.
|
59
|
+
|
60
|
+
Each JWT is granted access to specific Application and has a limited lifetime that is configured by you. However, best practice is to generate JWT for the shortest amount of time feasible for your application.
|
61
|
+
Here is an example of how to generate a JWT:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'virgil/crypto'
|
65
|
+
require 'virgil/jwt'
|
66
|
+
include Virgil::Crypto
|
67
|
+
include Virgil::Jwt
|
68
|
+
|
69
|
+
# API_KEY (you got this Key at Virgil Dashboard)
|
70
|
+
api_key_base64 = "MIGhMF0GCSqGSIb3DQEFDTBQMC8GCSqGSIb3DQEFDDAiBBC7Sg/DbNzhJ/uakTvafUMoAgIUtzAKBggqhkiG9w0CCjAdBglghkgBZQMEASoEEDunQ1yhWZoKaLaDFgjpxRwEQAFdbC8e6103lJrUhY9ahyUA8+4rTJKZCmdTlCDPvoWH/5N5kxbOvTtbxtxevI421z3gRbjAtoWkfWraSLD6gj0="
|
71
|
+
private_key_data = Bytes.from_string(api_key_base64, VirgilStringEncoding::BASE64)
|
72
|
+
|
73
|
+
# Crypto library imports a private key into a necessary format
|
74
|
+
crypto = VirgilCrypto.new
|
75
|
+
api_key = crypto.import_private_key(private_key_data, app_key_password)
|
76
|
+
|
77
|
+
# initialize accessTokenSigner that signs users JWTs
|
78
|
+
access_token_signer = VirgilAccessTokenSigner.new
|
79
|
+
|
80
|
+
# use your App Credentials you got at Virgil Dashboard:
|
81
|
+
app_id = "be00e10e4e1f4bf58f9b4dc85d79c77a" # APP_ID
|
82
|
+
api_key_id = "70b447e321f3a0fd"; # API_KEY_ID
|
83
|
+
ttl = 1*60 # 1 hour (JWT's lifetime in minutes)
|
84
|
+
|
85
|
+
# setup JWT generator with necessary parameters:
|
86
|
+
jwt_generator = JwtGenerator.new(app_id: app_id,
|
87
|
+
api_key: api_key,
|
88
|
+
api_public_key_id: api_key_id,
|
89
|
+
life_time: ttl,
|
90
|
+
access_token_signer: access_token_signer)
|
91
|
+
|
92
|
+
# generate JWT for a user
|
93
|
+
# remember that you must provide each user with his unique JWT
|
94
|
+
# each JWT contains unique user's identity (in this case - Alice)
|
95
|
+
# identity can be any value: name, email, some id etc.
|
96
|
+
identity = "Alice"
|
97
|
+
alice_jwt = jwt_generator.generate_token(identity)
|
98
|
+
|
99
|
+
# as result you get users JWT, it looks like this: "eyJraWQiOiI3MGI0NDdlMzIxZjNhMGZkIiwidHlwIjoiSldUIiwiYWxnIjoiVkVEUzUxMiIsImN0eSI6InZpcmdpbC1qd3Q7dj0xIn0.eyJleHAiOjE1MTg2OTg5MTcsImlzcyI6InZpcmdpbC1iZTAwZTEwZTRlMWY0YmY1OGY5YjRkYzg1ZDc5Yzc3YSIsInN1YiI6ImlkZW50aXR5LUFsaWNlIiwiaWF0IjoxNTE4NjEyNTE3fQ.MFEwDQYJYIZIAWUDBAIDBQAEQP4Yo3yjmt8WWJ5mqs3Yrqc_VzG6nBtrW2KIjP-kxiIJL_7Wv0pqty7PDbDoGhkX8CJa6UOdyn3rBWRvMK7p7Ak"
|
100
|
+
# you can provide users with JWT at registration or authorization steps
|
101
|
+
# Send a JWT to client-side
|
102
|
+
jwt_string = alice_jwt.to_s
|
103
|
+
```
|
104
|
+
|
105
|
+
### Manage a JWT
|
106
|
+
|
107
|
+
Each JWT consists of three parts: the `header`, the `payload`, and the `signature`.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# JWT Token structure
|
111
|
+
header.payload.signature
|
112
|
+
```
|
113
|
+
#### Header
|
114
|
+
|
115
|
+
The header contains information about how the JWT signature should be computed. The header is a JSON object in the following format:
|
116
|
+
```ruby
|
117
|
+
{
|
118
|
+
# the type of token. It MUST be "JWT"
|
119
|
+
"typ": "JWT",
|
120
|
+
# Signature algorithm. Currently supports only "VEDS512" (Virgil EdDSA SHA512)
|
121
|
+
"alg": "VEDS512",
|
122
|
+
# the content-type. It MUST be "virgil-jwt;v=1
|
123
|
+
"cty": "virgil-jwt;v=1",
|
124
|
+
# fingerprint of public key, that will be used to verify token. Equals to first 8 bytes of SHA512 of Public Key in DER format
|
125
|
+
"kid": "70b447e321f3a0fd"
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Payload
|
130
|
+
|
131
|
+
The payload is the data that‘s stored inside the JWT (this data is also referred to as the “claims” of the JWT). In our example, the Application server creates a JWT with the user information stored inside of it.
|
132
|
+
```ruby
|
133
|
+
{
|
134
|
+
# Issuer. Equals to virgil-
|
135
|
+
"iss": "virgil-be00e10e4e1f4bf58f9b4dc85d79c77a",
|
136
|
+
# Subject. Equals to identity-
|
137
|
+
"sub": "identity-Alice",
|
138
|
+
# Issued at. Utc timestamp that indicates when token was issued.
|
139
|
+
"iat": 1518612517,
|
140
|
+
# Expires at. Utc timestamp that shows when token will expire. Tokens have a maximum age of 24 hours
|
141
|
+
"exp": 1518698917
|
142
|
+
}
|
143
|
+
```
|
144
|
+
Keep in mind that the size of the data will affect the overall size of the JWT. This generally isn’t an issue but having excessively large JWT may negatively affect performance and cause latency.
|
145
|
+
|
146
|
+
#### Signature
|
147
|
+
|
148
|
+
The signature section is a signed hash that serves to prove the authenticity of the token. It is compiled by hashing the JWT header and payload together with your API Key secret, which should only be known to your application and Virgil.
|
149
|
+
The signature is computed using the following pseudo code:
|
150
|
+
```ruby
|
151
|
+
# Signature
|
152
|
+
signature = Base64.urlsafe_encode64(EdDSA+SHA512(SHA512(Base64.urlsafe_encode64(header) + "." + Base64.urlsafe_encode64(payload))))
|
153
|
+
```
|
154
|
+
Base64.urlsafe_encode64 encodes the header and the payload that was created in steps 1 and 2. The algorithm then joins the resulting encoded strings together with a period `(.)` in between them. To get the JWT signature, the data string is hashed with the secret key using the hashing algorithm specified in the JWT header.
|
155
|
+
Then, using the joined encoded header and payload and applying the specified signature algorithm(HS256) on the data string with the secret key set as the string “secret”, we get the JWT Signature.
|
156
|
+
Now that we have created all three components, we can create the JWT. Remembering the header.payload.signature structure of the JWT, we simply need to combine the components with periods `(.)` separating them. We use the Base64.urlsafe_encode64 encoded versions of the `header` and of the `payload`, and the `signature`.
|
157
|
+
|
158
|
+
Here is an example of JWT:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
# JWT Token
|
162
|
+
eyJraWQiOiI3MGI0NDdlMzIxZjNhMGZkIiwidHlwIjoiSldUIiwiYWxnIjoiVkVEUzUxMiIsImN0eSI6InZpcmdpbC1qd3Q7dj0xIn0.eyJleHAiOjE1MTg2OTg5MTcsImlzcyI6InZpcmdpbC1iZTAwZTEwZTRlMWY0YmY1OGY5YjRkYzg1ZDc5Yzc3YSIsInN1YiI6ImlkZW50aXR5LUFsaWNlIiwiaWF0IjoxNTE4NjEyNTE3fQ.MFEwDQYJYIZIAWUDBAIDBQAEQP4Yo3yjmt8WWJ5mqs3Yrqc_VzG6nBtrW2KIjP-kxiIJL_7Wv0pqty7PDbDoGhkX8CJa6UOdyn3rBWRvMK7p7Ak
|
163
|
+
```
|
164
|
+
|
165
|
+
It is important to understand that the purpose of using JWT is NOT to hide or obscure data in any way. The reason why JWT is used is to prove that the sent data was actually created by an authentic source.
|
166
|
+
You can try creating your own JWT through your browser at [jwt.io](https://jwt.io).
|
167
|
+
|
168
|
+
## Installation
|
169
|
+
|
170
|
+
TThe Virgil JWT is provided as a [gem](https://rubygems.org/) named [*virgil-jwt*](https://rubygems.org/gems/virgil-jwt) and available for Ruby 2.1 and newer. The package is distributed via *bundler* package manager.
|
171
|
+
|
172
|
+
To install the package use the command below:
|
173
|
+
|
174
|
+
```
|
175
|
+
gem install virgil-crypto
|
176
|
+
gem install virgil-jwt
|
177
|
+
```
|
178
|
+
|
179
|
+
or add the following line to your Gemfile:
|
180
|
+
|
181
|
+
```
|
182
|
+
gem 'virgil-crypto', '~> 3.6.2'
|
183
|
+
gem 'virgil-jwt'
|
184
|
+
```
|
185
|
+
and then run
|
186
|
+
|
187
|
+
```
|
188
|
+
bundle
|
189
|
+
```
|
190
|
+
## Docs
|
191
|
+
- [Crypto Core Library](https://github.com/VirgilSecurity/virgil-crypto)
|
192
|
+
- [More usage examples](https://developer.virgilsecurity.com/docs/how-to#cryptography)
|
193
|
+
|
194
|
+
## License
|
195
|
+
|
196
|
+
This library is released under the [3-clause BSD License](https://github.com/VirgilSecurity/virgil-sdk-javascript/blob/master/LICENSE).
|
197
|
+
|
198
|
+
## Support
|
199
|
+
Our developer support team is here to help you. Find out more information on our [Help Center](https://help.virgilsecurity.com/).
|
200
|
+
|
201
|
+
You can find us on [Twitter](https://twitter.com/VirgilSecurity) or send us email support@VirgilSecurity.com.
|
202
|
+
|
203
|
+
Also, get extra help from our support team on [Slack](https://virgilsecurity.com/join-community).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "virgil/sdk/ruby/jwt"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/virgil/jwt.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'virgil/jwt/version'
|
2
|
+
require 'virgil/jwt/access_token'
|
3
|
+
require 'virgil/jwt/access_token_provider'
|
4
|
+
require 'virgil/jwt/bytes'
|
5
|
+
require 'virgil/jwt/caching_jwt_provider'
|
6
|
+
require 'virgil/jwt/callback_jwt_provider'
|
7
|
+
require 'virgil/jwt/const_access_token_provider'
|
8
|
+
require 'virgil/jwt/token_context'
|
9
|
+
require 'virgil/jwt/jwt'
|
10
|
+
require 'virgil/jwt/jwt_body_content'
|
11
|
+
require 'virgil/jwt/jwt_generator'
|
12
|
+
require 'virgil/jwt/jwt_header_content'
|
13
|
+
require 'virgil/jwt/validation'
|
14
|
+
require 'virgil/jwt/jwt_verifier'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (C) 2015-2019 Virgil Security Inc.
|
2
|
+
#
|
3
|
+
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
4
|
+
#
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in
|
16
|
+
# the documentation and/or other materials provided with the
|
17
|
+
# distribution.
|
18
|
+
#
|
19
|
+
# (3) Neither the name of the copyright holder nor the names of its
|
20
|
+
# contributors may be used to endorse or promote products derived from
|
21
|
+
# this software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
24
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
27
|
+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
+
# SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
|
+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
31
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
32
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
|
35
|
+
module Virgil
|
36
|
+
module Jwt
|
37
|
+
class AccessToken
|
38
|
+
# Gets token identity.
|
39
|
+
# @return [String]
|
40
|
+
def identity
|
41
|
+
raise NotImplementedError
|
42
|
+
end
|
43
|
+
|
44
|
+
# Gets token string representation.
|
45
|
+
# @return [String]
|
46
|
+
def string_representation
|
47
|
+
raise NotImplementedError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (C) 2015-2019 Virgil Security Inc.
|
2
|
+
#
|
3
|
+
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
4
|
+
#
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer in
|
16
|
+
# the documentation and/or other materials provided with the
|
17
|
+
# distribution.
|
18
|
+
#
|
19
|
+
# (3) Neither the name of the copyright holder nor the names of its
|
20
|
+
# contributors may be used to endorse or promote products derived from
|
21
|
+
# this software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
24
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
27
|
+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
+
# SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
|
+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
31
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
32
|
+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
|
35
|
+
module Virgil
|
36
|
+
module Jwt
|
37
|
+
class AccessTokenProvider
|
38
|
+
# Gets access token.
|
39
|
+
# @param token_context [TokenContext]
|
40
|
+
# @return [AccessToken] Access token
|
41
|
+
def get_token(token_context)
|
42
|
+
raise NotImplementedError
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|