Chore Account server

Check-in [82fbdb4e98]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bringup, account server
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:82fbdb4e98c611b170ef993f4c23b30f356352c95cf5471e93e4b47e784d0ed4
User & Date: ajv-899-334-8894@vsta.org 2016-11-13 20:09:52
Context
2016-11-14
17:35
Old pdb hook check-in: 983353d070 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-11-13
20:09
Bringup, account server check-in: 82fbdb4e98 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-10-31
21:28
Bringup, account server connection check-in: 26b310cf55 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to .gitignore.

1
2
3

chore
*.pyc
*.real




>
1
2
3
4
chore
*.pyc
*.real
certs

Changes to get.py.

43
44
45
46
47
48
49





50
51
52
53
54
55
56
        return buf

    # Show portal of services
    def send_portal(self):
        server = self.server
        app = server.approot






        buf = self.build_header("Service Portal")
        buf += "<h3>Choose a service:</h3><br>\n"
        cfg = app.accts.get(self.user)
        if cfg is None:
            raise Exception, "Unknown account authenticated"
        services = cfg.get("serve")








>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
        return buf

    # Show portal of services
    def send_portal(self):
        server = self.server
        app = server.approot

        # Shouldn't be here without a cookie
        res = self.auth_cookie()
        if res is not True:
            return self.send401("Not logged in")

        buf = self.build_header("Service Portal")
        buf += "<h3>Choose a service:</h3><br>\n"
        cfg = app.accts.get(self.user)
        if cfg is None:
            raise Exception, "Unknown account authenticated"
        services = cfg.get("serve")

Changes to main.py.

153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
...
170
171
172
173
174
175
176



177
178
179
180
181
182
183
...
234
235
236
237
238
239
240

241
242
243
244
245
246
247
248
249
250
251
252



253
254
255
256
257
258
259
#  also refresh expiring cookies via a new round of authentication
#  before landing on their desired service.
#
# cfg{} - Top-level configuration
# accts{},accts_tm - Config of accounts, and st_mtime when read
# magics{} - Map from server ID to magic value (to detect
#       corrupt or mis-directed traffic)
class AccountsServer(chore.server.Server):

    def __init__(self, cfg, domain="chore"):
        self.domain = domain

        # Static account config
        self.cfg = cfg

        # Per-server magic values
................................................................................
        # Services, as they register to us.
        # Map from service name to (PID, port#, socket-name)
        self.services = {}

        # Load current version of accounts
        self.accts,self.accts_tm = load_accounts(cfg["accounts"])




        # Let Chore code set up the rest
        chore.server.Server.__init__(self, cfg, Account_Handler)

    # If account file is newer, reload
    def check_accounts(self):
        st = os.stat(self.cfg["accounts"])
        if st.st_mtime > self.accts_tm:
................................................................................
                (self.magics[resp] != req["magic"]):
            sys.stderr.write("Bad magic from '%s'\n" % (resp,))
            return

        # Check cookie
        if op == "cookie?":
            # Correct format?

            tup = self.parse_cookie(req.get("cookie", "XXX"))
            if tup is None:
                self.reply("?format", req)
                return

            # Ok cookie value?
            user,cookie = tup
            if not self.valid_cookie(user, cookie):
                self.reply("?authen", req)
                return

            # Let them on



            self.reply("OK", req)
            return

        # Unknown
        sys.stderr.write("Unknown op '%s' from '%s'\n" %
            (op, resp))
        self.reply(resp, req["op"], "?Bad-op")







|
>







 







>
>
>







 







>
|











>
>
>







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#  also refresh expiring cookies via a new round of authentication
#  before landing on their desired service.
#
# cfg{} - Top-level configuration
# accts{},accts_tm - Config of accounts, and st_mtime when read
# magics{} - Map from server ID to magic value (to detect
#       corrupt or mis-directed traffic)
class AccountsServer(chore.server.Server,
        chore.authen.Authen_Server_mixin):
    def __init__(self, cfg, domain="chore"):
        self.domain = domain

        # Static account config
        self.cfg = cfg

        # Per-server magic values
................................................................................
        # Services, as they register to us.
        # Map from service name to (PID, port#, socket-name)
        self.services = {}

        # Load current version of accounts
        self.accts,self.accts_tm = load_accounts(cfg["accounts"])

        # Initialize authen handling
        chore.authen.Authen_Server_mixin.__init__(self)

        # Let Chore code set up the rest
        chore.server.Server.__init__(self, cfg, Account_Handler)

    # If account file is newer, reload
    def check_accounts(self):
        st = os.stat(self.cfg["accounts"])
        if st.st_mtime > self.accts_tm:
................................................................................
                (self.magics[resp] != req["magic"]):
            sys.stderr.write("Bad magic from '%s'\n" % (resp,))
            return

        # Check cookie
        if op == "cookie?":
            # Correct format?
            pdb.set_trace()
            tup = chore.authen.parse_cookie(req.get("cookie", "XXX"))
            if tup is None:
                self.reply("?format", req)
                return

            # Ok cookie value?
            user,cookie = tup
            if not self.valid_cookie(user, cookie):
                self.reply("?authen", req)
                return

            # Let them on
            tup = self.cookies[user]
            req["user"] = user
            req["expires"] = tup[1]
            self.reply("OK", req)
            return

        # Unknown
        sys.stderr.write("Unknown op '%s' from '%s'\n" %
            (op, resp))
        self.reply(resp, req["op"], "?Bad-op")