acmesmith-designate 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8517d7e4f79b0be752b63d06f43b0e0b87c5c3e4
4
+ data.tar.gz: b2d51b8063b1a8bb26712ef9f215df8246181c48
5
+ SHA512:
6
+ metadata.gz: f32f9ff6ee0b5d8d2a6dd714f11c3c72ce8231c6e5c4c1283412052626df18f435ac92e540bffcf92e40b66b4c999ebcb50f9bf4b62e9965dfdee4193893627e
7
+ data.tar.gz: 707c6dc76f332a997c2f7e143b596c3ab5c6c805fe98ec1f1e92851b4bd7f4047bb517aad5c0ba53488a08fc73f68f4a43f866a61eebe4e7ecbc74da49518339
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Kasumi Hanazuki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # acmesmith-designate
2
+
3
+ This gem is a plugin for [acmesmith](https://github.com/sorah/acmesmith) and implements an automated `dns-01` challenge responder using OpenStack Designate.
4
+ It currently only supports Designate v1 API and tested with [ConoHa](https://www.conoha.jp/conoha).
5
+
6
+ ## Usage
7
+ You can use `designate` challenge responder in your `acmesmith.yml`.
8
+
9
+ ```yaml
10
+ challenge_responders:
11
+ - designate:
12
+ identity: # (optional) missing values are obtained from OS_* environment variables
13
+ auth_url: https://keystone.openstack.example.com/
14
+ tenant_name: your-tenant
15
+ username: conoha-chan
16
+ password: PASSW@RD
17
+ ttl: 5 # (optional) long TTL hinders re-authorization, but a DNSaaS provider may restrict short TTL
18
+ ```
19
+
20
+ ## License
21
+
22
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'acmesmith-designate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'acmesmith-designate'
8
+ spec.version = AcmesmithDesignate::VERSION
9
+ spec.authors = ['Kasumi Hanazuki']
10
+ spec.email = ['kasumi@rollingapple.net']
11
+
12
+ spec.summary = %q{acmesmith plugin implementing dns-01 using OpenStack Designate}
13
+ spec.description = %q{This gem is a plugin for acmesmith and implements an automated dns-01 challenge responder using OpenStack Designate.}
14
+ spec.homepage = 'https://github.com/hanazuki/acmesmith-designate'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split(?\0).reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'acmesmith'
23
+ spec.add_dependency 'yao-designate'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.11'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ end
@@ -0,0 +1,3 @@
1
+ module AcmesmithDesignate
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,61 @@
1
+ require 'acmesmith/challenge_responders/base'
2
+
3
+ require 'yao/designate'
4
+
5
+ module Acmesmith
6
+ module ChallengeResponders
7
+ class Designate < Base
8
+ def support?(type)
9
+ type == 'dns-01'
10
+ end
11
+
12
+ def initialize(config)
13
+ @config = config
14
+ config_yao(@config[:identity])
15
+ end
16
+
17
+ def respond(domain, challenge)
18
+ domain = canonicalize(domain)
19
+ find_zone(domain).records.create(
20
+ name: [challenge.record_name, domain].join(?.),
21
+ type: challenge.record_type,
22
+ data: challenge.record_content,
23
+ ttl: @config[:ttl],
24
+ )
25
+ end
26
+
27
+ def cleanup(domain, challenge)
28
+ domain = canonicalize(domain)
29
+ zone = find_zone(domain)
30
+ name = [challenge.record_name, domain].join(?.)
31
+ if record = zone.records.list.find {|r| r.name == name }
32
+ zone.records.destroy(record.id)
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def canonicalize(domain)
39
+ "#{domain}.".gsub(/\.{2,}/, '.')
40
+ end
41
+
42
+ def zones
43
+ @zones ||= Yao::Domain.list
44
+ end
45
+
46
+ def find_zone(domain)
47
+ zones.select {|z| domain =~ /(?:\A|\.)#{Regexp.escape(z.name)}\z/ }.max_by {|z| z.name.length } or
48
+ fail "Domain #{domain} is not configured in Designate"
49
+ end
50
+
51
+ def config_yao(identity)
52
+ Yao.config do
53
+ auth_url identity&.fetch('auth_url', ENV['OS_AUTH_URL'])
54
+ tenant_name identity&.fetch('tenant_name', ENV['OS_TENANT_NAME'])
55
+ username identity&.fetch('username', ENV['OS_USERNAME'])
56
+ password identity&.fetch('password', ENV['OS_PASSWORD'])
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acmesmith-designate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kasumi Hanazuki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: acmesmith
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yao-designate
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: This gem is a plugin for acmesmith and implements an automated dns-01
84
+ challenge responder using OpenStack Designate.
85
+ email:
86
+ - kasumi@rollingapple.net
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - acmesmith-designate.gemspec
97
+ - lib/acmesmith-designate/version.rb
98
+ - lib/acmesmith/challenge_responders/designate.rb
99
+ homepage: https://github.com/hanazuki/acmesmith-designate
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.5.1
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: acmesmith plugin implementing dns-01 using OpenStack Designate
123
+ test_files: []
124
+ has_rdoc: