darjeelink 0.11.6 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +68 -9
- data/app/assets/javascripts/darjeelink/tracking_link_generator.js +7 -2
- data/app/controllers/darjeelink/api_controller.rb +64 -0
- data/app/controllers/darjeelink/short_links_controller.rb +26 -13
- data/app/controllers/darjeelink/tracking_links_controller.rb +1 -0
- data/app/models/darjeelink/api_token.rb +14 -0
- data/app/models/darjeelink/short_link.rb +5 -7
- data/app/views/darjeelink/short_links/_short_link_form.erb +16 -13
- data/app/views/darjeelink/short_links/edit.html.erb +2 -9
- data/app/views/darjeelink/short_links/new.html.erb +6 -1
- data/app/views/darjeelink/tracking_links/new.erb +32 -21
- data/config/brakeman.ignore +26 -0
- data/config/initializers/darjeelink.rb +7 -6
- data/config/routes.rb +1 -0
- data/db/migrate/20210610083330_create_darjeelink_api_tokens.rb +15 -0
- data/lib/darjeelink/configuration.rb +1 -5
- data/lib/darjeelink/version.rb +1 -1
- metadata +34 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7381f9e369767b651245ade42dd0b4114696c5968991d5cf418f5662c7d759e
|
4
|
+
data.tar.gz: a523d01d431d7038ed2c843cf119fe1c8113100fcc2d1b90542d91f988f30acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097dc36dca7e4067e30d875e266589227e5536bfd235c9f391ea98fcaadc85dbe4542b0dae1adfb75a66f1bad72b9cfb0aa0454e65b099a2a1adba82678c24f1'
|
7
|
+
data.tar.gz: e83bc1c62cb18754f26f3891dae9502e9a3f87f0b20f37ac3f5b776a025552b2530e3724d7a35b471eb44d89051a79f3e5488a01f59b4d15d32bf13df9185720
|
data/README.md
CHANGED
@@ -19,17 +19,48 @@ There is a UTM generator, where you can provide:
|
|
19
19
|
- a campaign identifier
|
20
20
|
And you can get a link with UTM params all filled in, and shortern it with one click.
|
21
21
|
|
22
|
-
##
|
23
|
-
|
22
|
+
## API
|
23
|
+
There is an API available to create short links.
|
24
|
+
To create a short link via the API:
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
Nothing else required
|
26
|
+
First, create an api token `Darjeelink::ApiToken.create!(username: <username>, active: true)`.
|
27
|
+
Then grab the token.
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
Next, make a request
|
30
|
+
```
|
31
|
+
POST /api
|
32
|
+
Authorization => Token token=<username>:<token>
|
33
|
+
{
|
34
|
+
short_link: {
|
35
|
+
url: 'https://www.example.com',
|
36
|
+
shortened_path: 'xmpl' (optional)
|
37
|
+
}
|
38
|
+
}
|
39
|
+
```
|
40
|
+
`url` is the absolute URI that you wish to shorten
|
41
|
+
`shortened_path` is the path that you will visit to get redirected to your original link. It is optional. If it is not provided one will be generated automatically
|
32
42
|
|
43
|
+
If successful you will get a response like:
|
44
|
+
```
|
45
|
+
STATUS 201
|
46
|
+
{
|
47
|
+
short_link: <shortened_url>
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
If unsuccessful you will get a response like
|
52
|
+
```
|
53
|
+
STATUS 400
|
54
|
+
{
|
55
|
+
error: "information on what went wrong"
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
If authorization failed you will get a response like
|
60
|
+
```
|
61
|
+
STATUS 401
|
62
|
+
{}
|
63
|
+
```
|
33
64
|
## Installation
|
34
65
|
### Gemfile
|
35
66
|
Add these lines to your app's Gemfile
|
@@ -67,7 +98,35 @@ In `config/initializers/darjeelink.rb` edit the `config.source_mediums` hash.
|
|
67
98
|
|
68
99
|
Each key is a hyphenated source-medium. If you just want the source then omit the hyphen and medium.
|
69
100
|
|
70
|
-
Each value is a slightly more readable version for display
|
101
|
+
Each value is a slightly more readable version for display.
|
102
|
+
|
103
|
+
## Development
|
104
|
+
The recommended approach is to use Vagrant. `vagrant up` will create an isolated darjeelink instance.
|
105
|
+
Before you run `vagrant up`, make sure to create `.env.development` & `.env.test` files as detailed below.
|
106
|
+
|
107
|
+
### Setup development environment
|
108
|
+
Run `cp .env.sample spec/dummy/.env.development`
|
109
|
+
|
110
|
+
Nothing else required
|
111
|
+
|
112
|
+
### Setup test environment
|
113
|
+
Run `cp .env.sample spec/dummy/.env.test`
|
114
|
+
|
115
|
+
Change the database url to be different to the development one i.e. `postgres://darjeelink_dbuser:password@localhost/darjeelink-test`
|
116
|
+
|
117
|
+
## Releasing
|
118
|
+
Darjeelink follows [Semantic Versioning](https://semver.org)
|
119
|
+
|
120
|
+
Once all necessary changes have made it in to master and you are ready to do a release you need to do these steps.
|
121
|
+
|
122
|
+
Note that if you are running in a vagrant VM, most of these steps can be done from within the VM.
|
123
|
+
|
124
|
+
- Update `lib/darjeelink/version.rb` to the new version
|
125
|
+
- Run `bundle install` to pick up the change in Gemfile.lock
|
126
|
+
- Commit the changes to `lib/darjeelink/version.rb` and `Gemfile.lock`, and push them to GitHub
|
127
|
+
- Go to `https://github.com/38degrees/darjeelink/releases` and create a release tag in GitHub
|
128
|
+
- Run `gem build darjeelink.gemspec` this will output a file `darjeelink-X.X.X.gem` the version should match what version.rb and github.
|
129
|
+
- Run `gem push darjeelink-X.X.X.gem`
|
71
130
|
|
72
131
|
## GDPR
|
73
132
|
No personally identifiable data is stored about the public by this gem.
|
@@ -1,5 +1,10 @@
|
|
1
1
|
function generateTrackingLink(){
|
2
|
-
var url = $('#url').val();
|
2
|
+
var url = $('#base-url').val();
|
3
|
+
if (!url) {
|
4
|
+
document.getElementById("long_url").value = "";
|
5
|
+
return;
|
6
|
+
}
|
7
|
+
|
3
8
|
var sourceMedium = $('#source-medium').val();
|
4
9
|
var source = sourceMedium.split('-')[0];
|
5
10
|
var medium = sourceMedium.split('-')[1];
|
@@ -28,7 +33,7 @@ $(document).ready(function(){
|
|
28
33
|
generateTrackingLink();
|
29
34
|
});
|
30
35
|
|
31
|
-
$("#tracking").
|
36
|
+
$("#tracking").keyup(function(){
|
32
37
|
generateTrackingLink();
|
33
38
|
});
|
34
39
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Darjeelink
|
4
|
+
class ApiController < Darjeelink::ApplicationController
|
5
|
+
skip_before_action :check_ip_whitelist
|
6
|
+
skip_before_action :authenticate
|
7
|
+
|
8
|
+
before_action :authenticate_token
|
9
|
+
|
10
|
+
def create
|
11
|
+
short_link = Darjeelink::ShortLink.create!(short_link_params)
|
12
|
+
|
13
|
+
render(
|
14
|
+
json: { short_link: "#{Darjeelink.domain}/#{short_link.shortened_path}" },
|
15
|
+
status: :created
|
16
|
+
)
|
17
|
+
rescue ActiveRecord::RecordNotUnique
|
18
|
+
render(
|
19
|
+
json: { error: "#{short_link_params[:shortened_path]} already used! Choose a different custom path" },
|
20
|
+
status: :bad_request
|
21
|
+
)
|
22
|
+
rescue ActiveRecord::RecordInvalid => e
|
23
|
+
render(
|
24
|
+
json: { error: e.message.to_s },
|
25
|
+
status: :bad_request
|
26
|
+
)
|
27
|
+
rescue ActionController::ParameterMissing
|
28
|
+
render(
|
29
|
+
json: { error: 'Missing required params' },
|
30
|
+
status: :bad_request
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def short_link_params
|
37
|
+
params.require(:short_link).permit(:url, :shortened_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def authenticate_token
|
41
|
+
# The Authorization header must be supplied in the following format:
|
42
|
+
# "Authorization" => "Token token=#{username}:#{token}"
|
43
|
+
authenticate_or_request_with_http_token do |username_token, _options|
|
44
|
+
# Perform token comparison; avoid timing attacks and length leaks
|
45
|
+
# See: https://thisdata.com/blog/timing-attacks-against-string-comparison/
|
46
|
+
return head(:unauthorized) unless valid_authorization_token?(username_token)
|
47
|
+
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid_authorization_token?(username_token)
|
53
|
+
username, token = username_token.split ':'
|
54
|
+
|
55
|
+
stored_token = ApiToken.find_by(username: username, active: true)&.token
|
56
|
+
return false if stored_token.nil?
|
57
|
+
|
58
|
+
ActiveSupport::SecurityUtils.secure_compare(
|
59
|
+
token,
|
60
|
+
stored_token
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -5,8 +5,8 @@ module Darjeelink
|
|
5
5
|
skip_before_action :check_ip_whitelist, only: :show
|
6
6
|
skip_before_action :authenticate, only: :show
|
7
7
|
|
8
|
-
before_action :check_url_present, only:
|
9
|
-
before_action :check_url_valid, only:
|
8
|
+
before_action :check_url_present, only: %i[create update]
|
9
|
+
before_action :check_url_valid, only: %i[create update]
|
10
10
|
|
11
11
|
class ShortLinkNotFoundError < StandardError
|
12
12
|
end
|
@@ -18,17 +18,13 @@ module Darjeelink
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def new
|
21
|
+
@short_link = Darjeelink::ShortLink.new
|
21
22
|
end
|
22
23
|
|
23
24
|
def create
|
24
|
-
|
25
|
-
Darjeelink::ShortLink.create!(
|
26
|
-
rescue ActiveRecord::RecordNotUnique
|
27
|
-
flash[:error] = "#{params[:shortened_path]} already used! Choose a different custom path"
|
28
|
-
return redirect_to(darjeelink.new_short_link_path)
|
25
|
+
handle_create_or_update(error_redirect_path: darjeelink.new_short_link_path) do
|
26
|
+
Darjeelink::ShortLink.create!(short_link_params)
|
29
27
|
end
|
30
|
-
|
31
|
-
redirect_to(darjeelink.short_links_path)
|
32
28
|
end
|
33
29
|
|
34
30
|
def edit
|
@@ -37,9 +33,10 @@ module Darjeelink
|
|
37
33
|
|
38
34
|
def update
|
39
35
|
@short_link = Darjeelink::ShortLink.find(params[:id])
|
40
|
-
@short_link.update!(short_link_params)
|
41
36
|
|
42
|
-
|
37
|
+
handle_create_or_update(error_redirect_path: darjeelink.edit_short_link_path(@short_link)) do
|
38
|
+
@short_link.update!(short_link_params)
|
39
|
+
end
|
43
40
|
end
|
44
41
|
|
45
42
|
def show
|
@@ -57,6 +54,22 @@ module Darjeelink
|
|
57
54
|
|
58
55
|
private
|
59
56
|
|
57
|
+
def handle_create_or_update(error_redirect_path:)
|
58
|
+
return unless block_given?
|
59
|
+
|
60
|
+
begin
|
61
|
+
yield
|
62
|
+
rescue ActiveRecord::RecordNotUnique
|
63
|
+
flash[:error] = "#{params[:shortened_path]} already used! Choose a different custom path"
|
64
|
+
return redirect_to(error_redirect_path)
|
65
|
+
rescue ActiveRecord::RecordInvalid => e
|
66
|
+
flash[:error] = e.message.to_s
|
67
|
+
return redirect_to(error_redirect_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
redirect_to(darjeelink.short_links_path)
|
71
|
+
end
|
72
|
+
|
60
73
|
def log_missing_shortlink(shortened_path)
|
61
74
|
Rails.logger.warn("ShortLink not found: #{shortened_path}")
|
62
75
|
end
|
@@ -95,14 +108,14 @@ module Darjeelink
|
|
95
108
|
end
|
96
109
|
|
97
110
|
def check_url_present
|
98
|
-
return if params[:url].present?
|
111
|
+
return if params[:short_link].present? && params[:short_link][:url].present?
|
99
112
|
|
100
113
|
flash[:error] = 'URL cannot be blank'
|
101
114
|
redirect_to(darjeelink.new_short_link_path)
|
102
115
|
end
|
103
116
|
|
104
117
|
def check_url_valid
|
105
|
-
return if params[:url] =~ URI::DEFAULT_PARSER.make_regexp
|
118
|
+
return if params[:short_link].present? && params[:short_link][:url] =~ URI::DEFAULT_PARSER.make_regexp
|
106
119
|
|
107
120
|
flash[:error] = 'URL is not valid. Does it have https:// and are there any spaces?'
|
108
121
|
redirect_to(darjeelink.new_short_link_path)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Darjeelink
|
4
|
+
class ApiToken < ApplicationRecord
|
5
|
+
validates :username, uniqueness: true
|
6
|
+
validates :token, length: { minimum: 32 }, uniqueness: true
|
7
|
+
|
8
|
+
before_validation :generate_token
|
9
|
+
|
10
|
+
def generate_token
|
11
|
+
self.token = SecureRandom.uuid if token.blank?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,9 +3,12 @@
|
|
3
3
|
module Darjeelink
|
4
4
|
class ShortLink < ApplicationRecord
|
5
5
|
after_save :generate_short_link
|
6
|
-
before_validation :strip_white_space
|
7
6
|
|
8
7
|
validates_presence_of :url
|
8
|
+
validates :url, :shortened_path, format: {
|
9
|
+
without: /\s/,
|
10
|
+
message: 'must not contain any whitespace (spaces, tabs, etc)'
|
11
|
+
}
|
9
12
|
|
10
13
|
class << self
|
11
14
|
def search(query)
|
@@ -47,12 +50,7 @@ module Darjeelink
|
|
47
50
|
i /= base
|
48
51
|
end
|
49
52
|
|
50
|
-
generated_path.join
|
51
|
-
end
|
52
|
-
|
53
|
-
def strip_white_space
|
54
|
-
url&.strip!
|
55
|
-
shortened_path&.strip!
|
53
|
+
generated_path.join.reverse
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end
|
@@ -7,18 +7,21 @@
|
|
7
7
|
</div>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
<div class="form-group">
|
11
|
+
<%= f.label :url %>
|
12
|
+
<%= f.url_field :url,
|
13
|
+
class: "form-control", id: 'long_url', value: short_link.url, required: true,
|
14
|
+
pattern: 'https?://[^\s]+', placeholder: 'https://www.example.com',
|
15
|
+
title: 'URL, starting http:// or https:// - no whitespace (space, tab, etc) allowed'
|
16
|
+
%>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="form-group">
|
20
|
+
<%= f.label :custom_path %>
|
21
|
+
<%= f.text_field :shortened_path,
|
22
|
+
class: "form-control", id: 'shortened_path', value: short_link.shortened_path,
|
23
|
+
pattern: '[^\s]*', title: 'Short path - no whitespace (space, tab, etc) allowed'
|
24
|
+
%>
|
25
|
+
</div>
|
23
26
|
</div>
|
24
27
|
</div>
|
@@ -13,16 +13,9 @@
|
|
13
13
|
<div class="row">
|
14
14
|
<div class="col-md-12">
|
15
15
|
<%= form_for @short_link, url: darjeelink.short_link_path do |f| %>
|
16
|
-
|
17
|
-
<%= f.label :url %>
|
18
|
-
<%= f.url_field :url, class: "form-control", value: @short_link.url %>
|
19
|
-
</div>
|
20
|
-
<div class="form-group">
|
21
|
-
<%= f.label :custom_path %>
|
22
|
-
<%= f.text_field :shortened_path, class: "form-control", value: @short_link.shortened_path %>
|
23
|
-
</div>
|
16
|
+
<%= render partial: 'short_link_form', locals: { f: f, short_link: @short_link } %>
|
24
17
|
<div>
|
25
|
-
|
18
|
+
<%= f.submit "Update Shortlink", class: "btn btn-primary" %>
|
26
19
|
</div>
|
27
20
|
<% end %>
|
28
21
|
</div>
|
@@ -9,4 +9,9 @@
|
|
9
9
|
<h1>New Short Link</h1>
|
10
10
|
</div>
|
11
11
|
</div>
|
12
|
-
<%=
|
12
|
+
<%= form_for @short_link, url: darjeelink.short_links_path, local: true do |f| %>
|
13
|
+
<%= render partial: 'short_link_form', locals: { f: f, short_link: @short_link } %>
|
14
|
+
<div>
|
15
|
+
<%= f.submit "Create Shortlink", class: "btn btn-primary" %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -14,35 +14,46 @@
|
|
14
14
|
</div>
|
15
15
|
</div>
|
16
16
|
|
17
|
-
|
18
|
-
<div class="
|
19
|
-
<
|
17
|
+
<%= form_for @short_link, url: darjeelink.short_links_path, local: true do |f| %>
|
18
|
+
<div class="row" id="tracking">
|
19
|
+
<div class="col-md-12">
|
20
20
|
<div class="form-group">
|
21
|
-
<label for="url">URL</label>
|
22
|
-
<input
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
<label for="base-url">URL</label>
|
22
|
+
<input
|
23
|
+
type="text" class="form-control" id="base-url" name="base-url" required=true
|
24
|
+
pattern="https?://[^\s]+" placeholder="https://www.example.com"
|
25
|
+
title="URL, starting http:// or https:// - no whitespace (space, tab, etc) allowed"
|
26
|
+
>
|
27
|
+
|
28
|
+
<label for="source-medium">Source - Medium</label>
|
29
|
+
<select class="form-control" id="source-medium" name="source-medium">
|
30
|
+
<%= options_for_select(Darjeelink.source_mediums.map { |k,v| [v,k] }) %>
|
28
31
|
</select>
|
32
|
+
|
29
33
|
<label for="campaign">ID / Identifier (lower-case, underscores only)</label>
|
30
|
-
<input
|
34
|
+
<input
|
35
|
+
type="text" class="form-control" id="campaign" name="campaign" pattern="[^\s]*"
|
36
|
+
title="ID for the campaign - no whitespace (space, tab, etc) allowed"
|
37
|
+
>
|
31
38
|
</div>
|
32
|
-
</
|
39
|
+
</div>
|
33
40
|
</div>
|
34
|
-
</div>
|
35
41
|
|
36
|
-
<div class="row">
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
<div class="row">
|
43
|
+
<div class="col-md-12">
|
44
|
+
<h2>Your tracking link</h2>
|
45
|
+
<button id="copy-btn" class="btn btn-info btn-sm" data-clipboard-target="#long_url">
|
46
|
+
<span class="glyphicon glyphicon-copy"></span>
|
47
|
+
</button>
|
48
|
+
</div>
|
42
49
|
</div>
|
43
|
-
</div>
|
44
50
|
|
45
|
-
<%= render partial: 'darjeelink/short_links/short_link_form' %>
|
51
|
+
<%= render partial: 'darjeelink/short_links/short_link_form', locals: { f: f, short_link: @short_link } %>
|
52
|
+
|
53
|
+
<div>
|
54
|
+
<%= f.submit "Create Tracking Link", class: "btn btn-primary" %>
|
55
|
+
</div>
|
56
|
+
<% end %>
|
46
57
|
|
47
58
|
<script>
|
48
59
|
new ClipboardJS('#copy-btn');
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"ignored_warnings": [
|
3
|
+
{
|
4
|
+
"warning_type": "Mass Assignment",
|
5
|
+
"warning_code": 70,
|
6
|
+
"fingerprint": "4c710243b0d9f3f174b1b0b465dcd19aca14b1f1a9658572b13a1172855b6ed7",
|
7
|
+
"check_name": "MassAssignment",
|
8
|
+
"message": "Parameters should be whitelisted for mass assignment",
|
9
|
+
"file": "app/controllers/darjeelink/short_links_controller.rb",
|
10
|
+
"line": 83,
|
11
|
+
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
|
12
|
+
"code": "params.permit!",
|
13
|
+
"render_path": null,
|
14
|
+
"location": {
|
15
|
+
"type": "method",
|
16
|
+
"class": "Darjeelink::ShortLinksController",
|
17
|
+
"method": "build_url"
|
18
|
+
},
|
19
|
+
"user_input": null,
|
20
|
+
"confidence": "Medium",
|
21
|
+
"note": "The params aren't being use to create a record, we just use it to merge params that might be present on the shortened url and the source url"
|
22
|
+
}
|
23
|
+
],
|
24
|
+
"updated": "2020-07-23 16:52:33 +0000",
|
25
|
+
"brakeman_version": "4.8.2"
|
26
|
+
}
|
@@ -14,14 +14,15 @@ Darjeelink.configure do |config|
|
|
14
14
|
'sms-blast': 'SMS Blast',
|
15
15
|
'google-advert': 'Google advert',
|
16
16
|
'instagram-advert': 'Instagram Advert',
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
chatbot: 'Chatbot',
|
18
|
+
template: 'Template',
|
19
|
+
other: 'Other',
|
20
|
+
spotify: 'Spotify',
|
21
|
+
youtube: 'Youtube',
|
22
22
|
'google-search': 'Google search',
|
23
23
|
'google-display': 'Google display',
|
24
|
-
'snapchat-advert': 'Snapchat Advert'
|
24
|
+
'snapchat-advert': 'Snapchat Advert',
|
25
|
+
'digitalorganiser-share': 'Digital Organiser'
|
25
26
|
}
|
26
27
|
|
27
28
|
config.auth_domain = ENV['AUTH_DOMAIN']
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateDarjeelinkApiTokens < ActiveRecord::Migration[6.1]
|
4
|
+
def change
|
5
|
+
create_table :darjeelink_api_tokens do |t|
|
6
|
+
t.string :token, null: false
|
7
|
+
t.string :username, null: false
|
8
|
+
t.boolean :active, null: false, default: false
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index(:darjeelink_api_tokens, :username, unique: true)
|
13
|
+
add_index(:darjeelink_api_tokens, :token, unique: true)
|
14
|
+
end
|
15
|
+
end
|
@@ -2,11 +2,7 @@
|
|
2
2
|
|
3
3
|
module Darjeelink
|
4
4
|
class Configuration
|
5
|
-
attr_accessor :domain
|
6
|
-
attr_accessor :source_mediums
|
7
|
-
attr_accessor :auth_domain
|
8
|
-
attr_accessor :rebrandly_api_key
|
9
|
-
attr_accessor :fallback_url
|
5
|
+
attr_accessor :domain, :source_mediums, :auth_domain, :rebrandly_api_key, :fallback_url
|
10
6
|
|
11
7
|
def initialize
|
12
8
|
@domain = nil
|
data/lib/darjeelink/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darjeelink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Hulme
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: omniauth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: omniauth-google-oauth2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '6'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rebrandly
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: brakeman
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: bundler-audit
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +192,7 @@ dependencies:
|
|
178
192
|
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
|
-
description:
|
195
|
+
description:
|
182
196
|
email:
|
183
197
|
- james@38degrees.org.uk
|
184
198
|
executables: []
|
@@ -193,6 +207,7 @@ files:
|
|
193
207
|
- app/assets/javascripts/darjeelink/sparkleh.js
|
194
208
|
- app/assets/javascripts/darjeelink/tracking_link_generator.js
|
195
209
|
- app/assets/stylesheets/darjeelink/application.css
|
210
|
+
- app/controllers/darjeelink/api_controller.rb
|
196
211
|
- app/controllers/darjeelink/application_controller.rb
|
197
212
|
- app/controllers/darjeelink/sessions_controller.rb
|
198
213
|
- app/controllers/darjeelink/short_links_controller.rb
|
@@ -202,6 +217,7 @@ files:
|
|
202
217
|
- app/importers/darjeelink/short_link_importer.rb
|
203
218
|
- app/jobs/darjeelink/application_job.rb
|
204
219
|
- app/mailers/darjeelink/application_mailer.rb
|
220
|
+
- app/models/darjeelink/api_token.rb
|
205
221
|
- app/models/darjeelink/application_record.rb
|
206
222
|
- app/models/darjeelink/short_link.rb
|
207
223
|
- app/views/darjeelink/short_links/_short_link_form.erb
|
@@ -210,6 +226,7 @@ files:
|
|
210
226
|
- app/views/darjeelink/short_links/new.html.erb
|
211
227
|
- app/views/darjeelink/tracking_links/new.erb
|
212
228
|
- app/views/layouts/darjeelink/application.html.erb
|
229
|
+
- config/brakeman.ignore
|
213
230
|
- config/initializers/darjeelink.rb
|
214
231
|
- config/initializers/omniauth.rb
|
215
232
|
- config/initializers/rebrandly.rb
|
@@ -218,16 +235,17 @@ files:
|
|
218
235
|
- db/migrate/20190304094710_case_insensitive_index_short_link_shortened_path.rb
|
219
236
|
- db/migrate/20200505220716_rename_portkey_short_links_to_darjeelink_short_links.rb
|
220
237
|
- db/migrate/20200505221026_rename_portkey_short_link_index.rb
|
238
|
+
- db/migrate/20210610083330_create_darjeelink_api_tokens.rb
|
221
239
|
- lib/darjeelink.rb
|
222
240
|
- lib/darjeelink/configuration.rb
|
223
241
|
- lib/darjeelink/engine.rb
|
224
242
|
- lib/darjeelink/version.rb
|
225
243
|
- lib/tasks/darjeelink.rake
|
226
|
-
homepage: https://github.com/
|
244
|
+
homepage: https://github.com/38degrees/darjeelink
|
227
245
|
licenses:
|
228
246
|
- MIT
|
229
247
|
metadata: {}
|
230
|
-
post_install_message:
|
248
|
+
post_install_message:
|
231
249
|
rdoc_options: []
|
232
250
|
require_paths:
|
233
251
|
- lib
|
@@ -235,16 +253,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
253
|
requirements:
|
236
254
|
- - ">="
|
237
255
|
- !ruby/object:Gem::Version
|
238
|
-
version: '
|
256
|
+
version: '2.7'
|
239
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
258
|
requirements:
|
241
259
|
- - ">="
|
242
260
|
- !ruby/object:Gem::Version
|
243
261
|
version: '0'
|
244
262
|
requirements: []
|
245
|
-
rubyforge_project:
|
263
|
+
rubyforge_project:
|
246
264
|
rubygems_version: 2.7.8
|
247
|
-
signing_key:
|
265
|
+
signing_key:
|
248
266
|
specification_version: 4
|
249
267
|
summary: URL Shortener
|
250
268
|
test_files: []
|