fradium 0.1.2 → 0.1.3
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/Gemfile.lock +3 -1
- data/README.md +6 -3
- data/exe/fradium +13 -0
- data/fradium.gemspec +1 -0
- data/lib/fradium/version.rb +1 -1
- data/lib/fradium.rb +23 -14
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac78d78887194303b1eb5146c87e0a2ed739cc4ebc7436302a1f03fa010df86
|
4
|
+
data.tar.gz: 0bdd1b2862746b1f27fce9b6627d8762a697c6ba73f4f8f7b5298d3af25cec5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b612f965e45f3f213aadb8636034c88c8f058175865c2e01d6192084833af4a32baee6dfd66ce670e37e938ce635f68da7bf8c8ad7de7e7085d7162d9cac4d28
|
7
|
+
data.tar.gz: e7709e202d1fc585cce9597554e5a79bfe700ec443ca7909308f74bd5a2569a38d9378b17be04f2945d993d1c94079cb8610b1ef71fd5a09418fede51838b735
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fradium (0.1.
|
4
|
+
fradium (0.1.3)
|
5
5
|
mysql2 (~> 0.5)
|
6
|
+
pg (~> 1.1)
|
6
7
|
sequel (~> 5.23)
|
7
8
|
sqlite3 (~> 1.4)
|
8
9
|
|
@@ -13,6 +14,7 @@ GEM
|
|
13
14
|
diff-lcs (1.3)
|
14
15
|
method_source (0.9.2)
|
15
16
|
mysql2 (0.5.2)
|
17
|
+
pg (1.1.4)
|
16
18
|
pry (0.12.2)
|
17
19
|
coderay (~> 1.1.0)
|
18
20
|
method_source (~> 0.9.0)
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ This software is licensed under the MIT license.
|
|
15
15
|
|
16
16
|
First of all, create a confiuration file called `.fradium.yaml` in your home directory and specify information needed to your RADIUS database. You can define multiple configuration sets called *profile*.
|
17
17
|
|
18
|
-
Supported databases are MySQL and MariaDB via `mysql2` adapter so far. It should be work with SQLite or PostgreSQL but still experimental.
|
18
|
+
Supported databases are MySQL and MariaDB via `mysql2` adapter so far. It should be work with SQLite 3 or PostgreSQL but still experimental.
|
19
19
|
|
20
20
|
```
|
21
21
|
default: # default profile
|
@@ -31,9 +31,11 @@ staging:
|
|
31
31
|
username: root
|
32
32
|
password:
|
33
33
|
database: radius_staging
|
34
|
+
|
35
|
+
sqlite: "sqlite:///path/to/sqlite_database.sqlite"
|
34
36
|
```
|
35
37
|
|
36
|
-
Profiles can be
|
38
|
+
Profiles can be chosen by `--profile` option. Specify like `--profile=targetprofile`. If not specified, profile named `default` will be refered by default. Parameters defined in this config file are passed to [Sequel#connect](https://www.rubydoc.info/github/evanfarrar/opensprints/Sequel.connect) method as-is.
|
37
39
|
|
38
40
|
### Further usage
|
39
41
|
|
@@ -41,7 +43,7 @@ It would be easy to use. Running `fradium` without any options will show the usa
|
|
41
43
|
|
42
44
|
```
|
43
45
|
usage:
|
44
|
-
|
46
|
+
fradium [--profile=profile] subcommand ...
|
45
47
|
|
46
48
|
subcommands as follows:
|
47
49
|
create <username> # create new user with password
|
@@ -49,6 +51,7 @@ subcommands as follows:
|
|
49
51
|
showall # show all users
|
50
52
|
showvalid # show valid(not expired) users
|
51
53
|
showexpired # show expired users
|
54
|
+
showexpiry # show expiry inforrmation
|
52
55
|
expire <username> # expire the user right now
|
53
56
|
unexpire <username> # unexpire the user
|
54
57
|
setexpire <username> <expiry date> # set expiry date (date must be parseable by Time#parse)
|
data/exe/fradium
CHANGED
@@ -42,6 +42,7 @@ subcommands as follows:
|
|
42
42
|
showall # show all users
|
43
43
|
showvalid # show valid(not expired) users
|
44
44
|
showexpired # show expired users
|
45
|
+
showexpiry # show expiry inforrmation
|
45
46
|
expire <username> # expire the user right now
|
46
47
|
unexpire <username> # unexpire the user
|
47
48
|
setexpire <username> <expiry date> # set expiry date (date must be parseable by Time#parse)
|
@@ -99,6 +100,18 @@ when 'showexpired'
|
|
99
100
|
puts e
|
100
101
|
end
|
101
102
|
|
103
|
+
when 'showexpiry'
|
104
|
+
@f.expiry.each do |e|
|
105
|
+
now = Time.now
|
106
|
+
expiry = Time.parse(e[:value])
|
107
|
+
|
108
|
+
print e[:username]
|
109
|
+
print "\t"
|
110
|
+
print expiry.iso8601
|
111
|
+
print "\tEXPIRED" if now > expiry
|
112
|
+
print "\n"
|
113
|
+
end
|
114
|
+
|
102
115
|
when 'expire'
|
103
116
|
@f.expire_user(ARGV[1])
|
104
117
|
|
data/fradium.gemspec
CHANGED
data/lib/fradium/version.rb
CHANGED
data/lib/fradium.rb
CHANGED
@@ -11,13 +11,7 @@ class Fradium
|
|
11
11
|
|
12
12
|
def initialize(params)
|
13
13
|
@params = params
|
14
|
-
|
15
|
-
case @params['adapter']
|
16
|
-
when 'sqlite'
|
17
|
-
@sequel = Sequel.connect("sqlite://#{@params['file']}")
|
18
|
-
else
|
19
|
-
@sequel = Sequel.connect(@params)
|
20
|
-
end
|
14
|
+
@sequel = Sequel.connect(@params)
|
21
15
|
end
|
22
16
|
|
23
17
|
def user_exists?(username)
|
@@ -54,6 +48,10 @@ class Fradium
|
|
54
48
|
target.update(value: password, attribute: 'Cleartext-Password')
|
55
49
|
end
|
56
50
|
|
51
|
+
def expiry
|
52
|
+
@sequel[:radcheck].where(attribute: 'Expiration')
|
53
|
+
end
|
54
|
+
|
57
55
|
def expired_users
|
58
56
|
now = Time.now
|
59
57
|
# a little bit redundant but for consistency
|
@@ -98,13 +96,24 @@ class Fradium
|
|
98
96
|
end
|
99
97
|
|
100
98
|
def dbconsole
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
case @sequel.adapter_scheme
|
100
|
+
when :mysql2
|
101
|
+
# I know this is not safe.
|
102
|
+
Kernel.exec({'MYSQL_PWD' => @params['password']},
|
103
|
+
'mysql',
|
104
|
+
"--pager=less -SF",
|
105
|
+
"--user=#{@params['username']}",
|
106
|
+
"--host=#{@params['host']}" ,
|
107
|
+
"#{@params['database']}")
|
108
|
+
when :postgres
|
109
|
+
Kernel.exec({'PGPASSWORD' => @params['password']},
|
110
|
+
'psql',
|
111
|
+
"--username=#{@params['username']}",
|
112
|
+
"--dbname=#{@params['database']}",
|
113
|
+
"--host=#{@params['host']}")
|
114
|
+
when :sqlite
|
115
|
+
Kernel.exec('sqlite3', @params)
|
116
|
+
end
|
108
117
|
end
|
109
118
|
|
110
119
|
def self.generate_random_password(length=10)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fradium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichiro IWAO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pg
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.1'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sequel
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|