Skip to content

add ssl support to webserver#1408

Merged
liiight merged 4 commits intoFlexget:developfrom
b2un0:develop
Sep 20, 2016
Merged

add ssl support to webserver#1408
liiight merged 4 commits intoFlexget:developfrom
b2un0:develop

Conversation

@b2un0
Copy link
Copy Markdown
Contributor

@b2un0 b2un0 commented Sep 16, 2016

Motivation for changes:

  • remote access to flexget

Detailed changes:

  • add ssl support to webserver.py (cherrypy)

Config usage if relevant (new plugin or updated schema):

web_server:
  bind: 0.0.0.0
  port: 3539
  ssl_certificate: '/etc/ssl/private/myCert.pem'
  ssl_private_key: '/etc/ssl/private/myKey.key'
api: yes
webui: yes

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 16, 2016

image

@stevezau
Copy link
Copy Markdown
Contributor

Ah! this has been on the todo list for a while..

I think we should support the generation of a self signed certificate?

'bind': {'type': 'string', 'format': 'ipv4', 'default': '0.0.0.0'},
'port': {'type': 'integer', 'default': 3539},
'ssl_certificate': {'type': 'string', 'format': 'string', 'default': ''},
'ssl_private_key': {'type': 'string', 'format': 'string', 'default': ''},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe in schema you can tell that both of these are required or neither.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are not required, if you don't set them, the webserver starts without ssl.

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 16, 2016

I think we should support the generation of a self signed certificate?
self signed certificate even works

@Tommatheussen
Copy link
Copy Markdown
Contributor

What I believe @stevezau meant is provide a way to the user that allows Flexget to create self-signed certificates

@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 16, 2016

@stevezau if that is what you meant, allow flexget to create the ssl, I don't think we need that.

I believe @paranoidi meant json schema dependencies: https://spacetelescope.github.io/understanding-json-schema/reference/object.html#dependencies

Specifically bidirectional dependencies.


log.info('Web interface available at http://%s:%s' % (host, self.port))
if self.ssl_certificate and self.ssl_private_key:
log.info('Web interface available at https://%s:%s' % (host, self.port))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let the logger handle string formatting ie. log.info('Web interface available at https://%s:%s' , host, self.port)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 18, 2016

Please set the schema to reflect a bidirectional dependency:

'depenedencies': {
  'ssl_certificate': ['ssl_private_key'],
  'ssl_private_key': ['ssl_certificate']
}

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 19, 2016

dependencies was added


if self.ssl_certificate and self.ssl_private_key:
log.info('Web interface available at https://%s:%s' % (host, self.port))
proto = 'https'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well call it protocol.

log.info('Web interface available at http://%s:%s' % (host, self.port))
proto = 'http'

log.info('Web interface available at %s://%s:%s' % (proto, host, self.port))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let the logger handle the string formatting here as well

@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 19, 2016

You forgot to change the logger formatting, that's the only thing left

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 20, 2016

i does not understand what you mean?!

@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 20, 2016

Change:
log.info('Web interface available at %s://%s:%s' % (protocol, host, self.port))
Into:
log.info('Web interface available at %s://%s:%s' ,protocol, host, self.port)
The logger module knows when it needs to interpolate the strings itself and it's considered a good practice.

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 20, 2016

ah, okay.

i just used the original line and add the protocol parameter;
https://github.com/Flexget/Flexget/blob/develop/flexget/webserver.py#L221

@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 20, 2016

yeah, it wasn't right before 😉
might as well do it right the second time.

@b2un0
Copy link
Copy Markdown
Contributor Author

b2un0 commented Sep 20, 2016

finally done :)

@liiight liiight merged commit 1c9c3f5 into Flexget:develop Sep 20, 2016
@liiight
Copy link
Copy Markdown
Member

liiight commented Sep 20, 2016

thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants