Merge lp://staging/~hazmat/pyjuju/rapi-login into lp://staging/~hazmat/pyjuju/rapi-rollup
Proposed by
Kapil Thangavelu
Status: | Merged |
---|---|
Merged at revision: | 624 |
Proposed branch: | lp://staging/~hazmat/pyjuju/rapi-login |
Merge into: | lp://staging/~hazmat/pyjuju/rapi-rollup |
Diff against target: |
256 lines (+84/-12) 6 files modified
juju/errors.py (+4/-0) juju/rapi/context.py (+9/-2) juju/rapi/tests/common.py (+1/-0) juju/rapi/tests/test_context.py (+3/-1) juju/rapi/transport/tests/test_ws.py (+47/-2) juju/rapi/transport/ws.py (+20/-7) |
To merge this branch: | bzr merge lp://staging/~hazmat/pyjuju/rapi-login |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kapil Thangavelu | Pending | ||
Review via email: mp+140268@code.staging.launchpad.net |
Description of the change
Require login before api usage.
This update requires login before using the ws api and before the delta stream is active.
To post a comment you must log in.
Reviewers: mp+140268_ code.launchpad. net,
Message:
Please take a look.
Description:
Add a login api
Login support using admin credentials/secret
https:/ /code.launchpad .net/~hazmat/ juju/rapi- login/+ merge/140268
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6935068/
Affected files: context. py tests/test_ context. py initialize. py tests/test_ initialize. py
A [revision details]
M juju/agents/api.py
M juju/rapi/
M juju/rapi/
M juju/state/
M juju/state/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/agents/api.py api.py' transport. ws import WebSocketAPIFactory
=== modified file 'juju/agents/
--- juju/agents/api.py 2012-09-10 03:43:29 +0000
+++ juju/agents/api.py 2012-12-12 19:30:20 +0000
@@ -11,6 +11,7 @@
from juju.errors import JujuError
from juju.lib.websockets import WebSocketsResource
from juju.rapi.
+from juju.state.auth import make_ace
from twisted.web.static import Data
log. debug(" Received environment data.")
self. ws_factory = WebSocketAPIFac tory( 'zookeeper_ servers' ], self.provider) 'zookeeper_ servers' ], self.provider) factory. startFactory( )
from twisted.web.server import Site
@@ -32,7 +33,7 @@
root = Data("Juju API Server\n", "text/plain")
- self.config[
+ self.config[
yield self.ws_
@@ -79,10 +80,30 @@
+ # Lazy initialize login nodes if not present. e_login( ) fig()
config. parse(environme nt_data)
returnValue( config. get_default( ))
+ yield self._initializ
+
config = EnvironmentsCon
+ @inlineCallbacks login(self) : get_children( "/") get_acl( "/initialized" ) .startswith( 'admin' ): ace(admin_ acl['id' ], all=True)])
super( APIEndpointAgen t, self).configure (options) get("port" ):
+ def _initialize_
+ children = yield self.client.
+ if "login" in children:
+ return
+
+ acls, stat = yield self.client.
+ admin_acl = None
+
+ for a in acls:
+ if a['id']
+ admin_acl = a
+ break
+
+ yield self.client.create(
+ "/login", acls=[make_
+
def configure(self, options):
if not options.
Index: juju/rapi/ context. py context. py' context. py 2012-10-12 20:49:45 +0000 context. py 2012-12-12 19:30:20 +0000 internet. defer import maybeDeferred, succeed internet. defer import (
=== modified file 'juju/rapi/
--- juju/rapi/
+++ juju/rapi/
@@ -1,5 +1,6 @@
from StringIO import StringIO
-from twisted.
+from twisted.
+ maybeDeferred, succeed, returnValue, inlineCallbacks)
from juju.rapi.cmd import add_relation
from juju.rapi.cmd import add_unit
@@ -22,7 +23,10 @@
from juju.rapi import rest
+from juju.state.security import Principal
+
...