shithub: purgatorio

ref: 82b046f36f8084a22bbb5d71edd0edd9179561eb
dir: /appl/cmd/auth/factotum/proto/pass.b/

View raw version
implement Authproto;

include "sys.m";
	sys: Sys;

include "../authio.m";
	authio:	Authio;
	Attr, IO: import authio;

init(f: Authio): string
{
	sys = load Sys Sys->PATH;
	authio = f;
	return nil;
}

interaction(attrs: list of ref Attr, io: ref Authio->IO): string
{
	(key, err) := io.findkey(attrs, "user? !password?");
	if(key == nil)
		return err;
	user := authio->lookattrval(key.attrs, "user");
	if(user == nil)
		return "unknown user";
	pass := authio->lookattrval(key.secrets, "!password");
	a := sys->aprint("%q %q", user, pass);
	io.write(a, len a);
	return nil;
}

keycheck(nil: ref Authio->Key): string
{
	return nil;
}