-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from velu-dev/dev
gemscpec changes and add some features in token
- Loading branch information
Showing
9 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
c | ||
decoded_token.present? | ||
decoded_token.present | ||
decoded_token | ||
c | ||
cc | ||
c | ||
decoded_token | ||
c | ||
decoded_token | ||
c | ||
exit | ||
decoded_token | ||
decode_token | ||
c | ||
rescue JWT::ImmatureSignature | ||
rescue JWT::ExpiredSignature | ||
decoded_token = JWT.decode token, nil, false | ||
c | ||
Kernel.const_get(gfd) | ||
Kernel.const_get() | ||
Kernel.const_get("fdgfd") | ||
Kernel.const_get(@model) | ||
Kernel.const_get(@model).find(@data['userid'].to_i) | ||
user = Kernel.const_get(@model).find(@data['userid'].to_i) | ||
time = @data['time'].to_time+ 1.hour > Time.now | ||
c | ||
decoded_token = JWT.decode token, nil, false | ||
@model = model | ||
model | ||
token | ||
exit | ||
Kernel.const_get(classname) | ||
Kernel.const_get(classname).methods | ||
classname = 'Integer' | ||
eval classname + '.methods' | ||
classname = 'Integer' | ||
Model(@data['userid']) | ||
@data['userid'] | ||
@data['userid'].capitalize! | ||
@data['userid'] | ||
@data['userid'].capitalize! | ||
@data['userid'] | ||
@data['userid'].capitalize! | ||
@data['userid'].capitalize!.new | ||
@data['userid'].capitalize! | ||
@data['userid'].Capitalize | ||
@data['userid'].Capitalize! | ||
@data['userid'] | ||
@data | ||
@data['time'].to_time+ 1.hour > Time.now | ||
@data['time'].to_time > Time.now | ||
@data['time'].to_time | ||
@data['time'] | ||
@data | ||
c | ||
@data = decoded_token[0]['data'] | ||
decoded_token = JWT.decode token, nil, false | ||
c | ||
exit | ||
decoded_token = JWT.decode @token, nil, false | ||
token | ||
tokken | ||
c | ||
@token | ||
c | ||
@token | ||
c | ||
@data['userid'] | ||
@data.userid | ||
@data | ||
exit | ||
@data['data'] | ||
@data | ||
@data' | ||
exit | ||
@data[0]['data']['userid'] | ||
@data[0]['data'].userid | ||
@data[0]['data'] | ||
@data[0] | ||
@data[0].data | ||
@data[0].dats | ||
@data[0].date | ||
@data[0] | ||
@data | ||
exit | ||
Time.now.to_s | ||
Time.now.to_s.to_i | ||
Time.now.to_s.to_time | ||
Time.now.to_s | ||
Time.now | ||
Date.today + "g" | ||
Date.today | ||
Date.today.to_s.split("-").join("") | ||
Date(Date.today.to_s.split("-").join("")) | ||
Date.today.to_s.split("-").join("").to_date | ||
Date.today.to_s.split("-").join("") | ||
Date.today.to_s.split("-") | ||
Date.today.to_s.split("") | ||
Date.today.to_s | ||
Date.today.to_a | ||
Date.today.to_s | ||
Date.today | ||
@date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
gem 'bcrypt', '~> 3.1', '>= 3.1.11' | ||
gem 'bcrypt', '~> 3.1', '>= 3.1.11' | ||
gem 'jwt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# Web Token Gem for simplification of JWT | ||
|
||
## Step 1 | ||
gem install webtoken | ||
|
||
## Step 2 | ||
|
||
require 'webtoken' | ||
## Step 3 | ||
|
||
data = WebToken::MakeToken.new( user_id ) | ||
|
||
data.web_token | ||
|
||
### Response | ||
|
||
#sample = {"eyJhbGciOiJub25lIn0.eyJkYXRhIjp7InVzZXJpZCI6ImpodiIsImRhdGUiOiIyMDE4LTA1LTI1IiwidGltZSI6IjIwMTgtMDUtMjUgMTI6Mzk6MzIgKzA1MzAifX0."} | ||
|
||
|
||
## Step 3 | ||
|
||
validate_token = WebToken::WebtokenValidate.new | ||
|
||
validate_token.validate( 'your token' ) | ||
|
||
### Response | ||
{"userid" : "userid", date: "date", time: "time"} #access token valid | ||
|
||
false #access token invalid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'active_support' | ||
require 'active_support/all' | ||
require 'fnv' | ||
require 'byebug' | ||
require 'bcrypt' | ||
require 'jwt' | ||
require "date" | ||
module WebToken | ||
class MakeToken | ||
def initialize( user_id ) | ||
data = { | ||
userid: user_id, | ||
date: Date.today.to_s, | ||
time: Time.now | ||
} | ||
payload = {:data => data} | ||
@token = JWT.encode payload, nil, 'none' | ||
# decoded_token = JWT.decode @token, nil, false | ||
# @data = decoded_token[0]['data'] | ||
end | ||
def web_token | ||
@token | ||
end | ||
# def data | ||
# @data | ||
# end | ||
|
||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'byebug' | ||
require 'bcrypt' | ||
require 'jwt' | ||
require "date" | ||
|
||
module WebToken | ||
|
||
class WebtokenValidate | ||
# def initialize( token, model ) | ||
|
||
# end | ||
def validate( token ) | ||
begin | ||
decoded_token = JWT.decode token, nil, false | ||
rescue JWT::ExpiredSignature | ||
rescue JWT::ImmatureSignature | ||
rescue JWT::DecodeError | ||
|
||
end | ||
if decoded_token.present? | ||
@data = decoded_token[0]['data'] | ||
time = @data['time'].to_time+ 1.hour > Time.now | ||
if time | ||
@data | ||
else | ||
false | ||
end | ||
else | ||
false | ||
end | ||
|
||
# user = Kernel.const_get(@model).find(@data['userid'].to_i) | ||
# if user.present? && time | ||
# user | ||
# else | ||
# return false | ||
# end | ||
end | ||
|
||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'active_support' | ||
require 'active_support/all' | ||
require 'fnv' | ||
require './lib/token/web_token_gen' | ||
require './lib/validation/token_validate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
lib = File.expand_path( '../lib/', __FILE__ ) | ||
$LOAD_PATH.unshift( lib ) unless $LOAD_PATH.include?( lib ) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'webtoken' | ||
s.version = '0.0.1' | ||
s.date = '2010-05-25' | ||
s.summary = "WebToken" | ||
s.description = "Simplify web token using JWT" | ||
s.authors = ["velusamy Venkatraman"] | ||
s.email = '[email protected],' | ||
s.files = ["lib/webtoken.rb"] | ||
# s.require_paths = [ "lib" ] | ||
s.homepage ='' | ||
s.license = 'MIT' | ||
end |