-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from mlibrary/delegation
Delegation
- Loading branch information
Showing
39 changed files
with
965 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
#include "lauth/authorizer.hpp" | ||
|
||
#include <map> | ||
#include <string> | ||
#include <numeric> | ||
|
||
namespace mlibrary::lauth { | ||
bool Authorizer::isAllowed(Request req) { | ||
return client->authorize(req).determination == "allowed"; | ||
std::string join(std::vector<std::string> elements, const std::string &separator) { | ||
return std::accumulate( | ||
begin(elements), | ||
end(elements), | ||
separator, | ||
[&separator](std::string result, std::string value) { | ||
return result + value + separator; | ||
} | ||
); | ||
} | ||
|
||
std::map<std::string, std::string> Authorizer::authorize(Request req) { | ||
AuthorizationResult result = client->authorize(req); | ||
return std::map<std::string, std::string> { | ||
{"determination", result.determination}, | ||
{"public_collections", join(result.public_collections, ":")}, | ||
{"authorized_collections", join(result.authorized_collections, ":")}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
-- target-cats is the collection that the user will request | ||
-- the user is authorized for this collection | ||
INSERT INTO aa_coll VALUES( | ||
'target-cats', -- uniqueIdentifier | ||
'target-cats', -- commonName | ||
'auth system testing: delegation', | ||
'catpics', -- dlpsClass | ||
'none', -- dlpsSource (unused) | ||
'pw', -- dlpsAuthenMethod | ||
'd', -- dlpsAuthzType | ||
'f', -- dlpsPartlyPublic | ||
0, -- manager | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
-- extra-cats is a private collection the user is authorized for | ||
INSERT INTO aa_coll VALUES( | ||
'extra-cats', -- uniqueIdentifier | ||
'extra-cats', -- commonName | ||
'auth system testing: delegation', | ||
'catpics', -- dlpsClass | ||
'none', -- dlpsSource (unused) | ||
'pw', -- dlpsAuthenMethod | ||
'd', -- dlpsAuthzType | ||
'f', -- dlpsPartlyPublic | ||
0, -- manager | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
-- secret-cats is a private collection the user is not authorized for | ||
INSERT INTO aa_coll VALUES( | ||
'secret-cats', -- uniqueIdentifier | ||
'secret-cats', -- commonName | ||
'auth system testing: delegation', | ||
'catpics', -- dlpsClass | ||
'none', -- dlpsSource (unused) | ||
'pw', -- dlpsAuthenMethod | ||
'd', -- dlpsAuthzType | ||
'f', -- dlpsPartlyPublic | ||
0, -- manager | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
-- public-cats is a public collection the user is not explicitly authorized for | ||
INSERT INTO aa_coll VALUES( | ||
'public-cats', -- uniqueIdentifier | ||
'public-cats', -- commonName | ||
'auth system testing: delegation', | ||
'catpics', -- dlpsClass | ||
'none', -- dlpsSource (unused) | ||
'pw', -- dlpsAuthenMethod | ||
'd', -- dlpsAuthzType | ||
't', -- dlpsPartlyPublic | ||
0, -- manager | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
-- extra-public-cats is a public collection the user is explicitly authorized for | ||
INSERT INTO aa_coll VALUES( | ||
'extra-public-cats', -- uniqueIdentifier | ||
'extra-public-cats', -- commonName | ||
'auth system testing: delegation', | ||
'catpics', -- dlpsClass | ||
'none', -- dlpsSource (unused) | ||
'pw', -- dlpsAuthenMethod | ||
'd', -- dlpsAuthzType | ||
't', -- dlpsPartlyPublic | ||
0, -- manager | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
-- we only need one location for these tests | ||
INSERT INTO aa_coll_obj VALUES( | ||
'www.lauth.local', -- server hostname, not vhost | ||
'/lauth/test-site/cgi/printenv', -- dlpsPath | ||
'target-cats', -- coll.uniqueIdentifier | ||
CURRENT_TIMESTAMP, 'root', -- modified info | ||
'f' -- deleted | ||
); | ||
|
||
INSERT INTO aa_may_access VALUES( | ||
NULL, -- uniqueIdentifier | ||
'lauth-allowed', -- userid | ||
NULL, -- user_grp | ||
NULL, -- inst | ||
'target-cats', -- coll | ||
CURRENT_TIMESTAMP, | ||
'root', | ||
NULL, | ||
'f' | ||
); | ||
|
||
INSERT INTO aa_may_access VALUES( | ||
NULL, -- uniqueIdentifier | ||
'lauth-allowed', -- userid | ||
NULL, -- user_grp | ||
NULL, -- inst | ||
'extra-cats', -- coll | ||
CURRENT_TIMESTAMP, | ||
'root', | ||
NULL, | ||
'f' | ||
); | ||
|
||
INSERT INTO aa_may_access VALUES( | ||
NULL, -- uniqueIdentifier | ||
'lauth-allowed', -- userid | ||
NULL, -- user_grp | ||
NULL, -- inst | ||
'extra-public-cats', -- coll | ||
CURRENT_TIMESTAMP, | ||
'root', | ||
NULL, | ||
'f' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.