Skip to content

Commit 14b40b6

Browse files
authored
DM-13112 merge pr #15 from lsst/dm-13112_lsstworkspace
DM-13112 LSST workspace (to use with firefly rc-2019.2)
2 parents 2561c9e + 12b0eb2 commit 14b40b6

File tree

5 files changed

+85
-8
lines changed

5 files changed

+85
-8
lines changed

config/app.config

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ sso.logout.url = "/oauth2/sign_in"
3232
sso.user.profile.url =
3333
__$help.base.url = "onlinehelp/"
3434

35-
3635
sso.framework.adapter = "edu.caltech.ipac.lsst.security.LsstSsoAdapter"
3736
sso.auth.required = "false"
3837
oidc_client_id = ""
@@ -58,6 +57,12 @@ lsst.dax.metaservURL = "/api/meta/v1/db/"
5857
lsst.dax.imgservURL = "/api/image/v1/"
5958
lsst.dax.imgserv.repository = "DC_W13_Stripe82"
6059

60+
// if workspace host url is empty, the url will be derived from request's host and protocol
61+
workspace.host.url = ""
62+
workspace.root.path = "/api/dav/scratch/dav"
63+
workspace.protocol.webdav = "edu.caltech.ipac.lsst.LsstWebDAVWorkspaceManager"
64+
__$workspace.propfind.infinity = false
65+
6166
// ehcache.xml env sensitive properties
6267
// ehcahe replication port; suggest 4077-developer, 5077-dev, 6077-I&T, 7077-Prod, 8077-Public
6368
ehcache.multicast.port = "7077"
@@ -78,6 +83,7 @@ environments{
7883
ehcache.multicast.address="239.255.0.1"
7984
ehcache.multicast.ttl = 0
8085
redis.host = "127.0.0.1"
86+
workspace.host.url = "https://lsst-lsp-int.ncsa.illinois.edu"
8187
}
8288
dev {
8389
BuildType = "Development"

config/suit.prop

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ oidc_client_id = @oidc_client_id@
3232
oidc_client_secret = @oidc_client_secret@
3333
oidc_redirect_uri = @sso_redirect_uri@
3434
__$sso_redirect_uri = @sso_redirect_uri@
35+
workspace.host.url = @workspace.host.url@
36+
workspace.protocol.webdav = @workspace.protocol.webdav@
37+
workspace.root.path = @workspace.root.path@
38+
workspace.propfind.infinity = @__$workspace.propfind.infinity@
3539

3640
redis.host = @redis.host@
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package edu.caltech.ipac.lsst;
2+
3+
import edu.caltech.ipac.firefly.data.WspaceMeta;
4+
import edu.caltech.ipac.firefly.server.WebDAVWorkspaceManagerBase;
5+
import edu.caltech.ipac.firefly.server.network.HttpServiceInput;
6+
import edu.caltech.ipac.firefly.server.ws.WsCredentials;
7+
import edu.caltech.ipac.util.AppProperties;
8+
9+
import java.util.Map;
10+
11+
/**
12+
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
13+
*
14+
* @author tatianag
15+
*/
16+
public class LsstWebDAVWorkspaceManager extends WebDAVWorkspaceManagerBase {
17+
18+
private static String WS_ROOT_PATH = AppProperties.getProperty("workspace.root.path", "/dav");
19+
20+
private WsCredentials creds;
21+
private String userHome;
22+
23+
public LsstWebDAVWorkspaceManager(String wsId) {
24+
25+
Map<String, String> cookies = HttpServiceInput.createWithCredential(getWsHostUrl()).getCookies(); // should look at this again.
26+
// for development from a local machine, set wsId to your user name
27+
// if (wsId == null || wsId.equals("Guest")) wsId = "tatianag";
28+
this.creds = new WsCredentials(wsId, cookies);
29+
this.userHome = WspaceMeta.ensureWsHomePath(wsId);
30+
}
31+
32+
public LsstWebDAVWorkspaceManager(WsCredentials cred) {
33+
this(cred.getWsId());
34+
}
35+
36+
@Override
37+
public WsCredentials getCredentials() {
38+
return this.creds;
39+
}
40+
41+
@Override
42+
public String getWsHome() {
43+
return WS_ROOT_PATH + this.userHome;
44+
}
45+
46+
// namespace is only used to set and save properties,
47+
// this feature is not used in the current implementation
48+
49+
@Override
50+
protected String getNamespacePrefix() {
51+
return "lsst";
52+
}
53+
54+
@Override
55+
protected String getNamespaceUri() {
56+
return getWsHostUrl()+"/namespace/";
57+
}
58+
}

src/suit/java/edu/caltech/ipac/lsst/security/LsstSsoAdapter.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import edu.caltech.ipac.util.StringUtils;
1414
import org.json.simple.parser.JSONParser;
1515

16-
import java.util.Arrays;
1716
import java.util.Base64;
1817
import java.util.List;
1918
import java.util.Map;
@@ -32,8 +31,10 @@ public class LsstSsoAdapter implements SsoAdapter {
3231

3332
private static final String ID_TOKEN = "X-Auth-Request-Token";
3433

35-
private static final String USER_NAME = "sub";
36-
private static final String UID = "uidNumber";
34+
// the keywords are listed in https://confluence.lsstcorp.org/display/LAAIM/Web+SSO
35+
private static final String USER_NAME = "sub"; // ex.value "http://cilogon.org/serverT/users/123456'
36+
private static final String UID_NUMBER = "uidNumber"; // ex.value "01234"
37+
private static final String UID = "uid"; // ex.value "username"
3738
private static final String MEMBER_OF = "isMemberOf";
3839
private static final String NAME = "name";
3940
private static final String EMAIL = "email";
@@ -49,11 +50,14 @@ public Token getAuthToken() {
4950
String id_token = getString(ra, ID_TOKEN, ""); // this is a 3-parts base64 encoded JWT token
5051
String[] parts = id_token.split("\\.");
5152
if (parts.length == 3) {
52-
Map claims = (Map) new JSONParser().parse(new String(Base64.getDecoder().decode(parts[1])));
53+
String jsonContent = new String(Base64.getDecoder().decode(parts[1]));
54+
//LOGGER.debug("CILogon User Info: " + jsonContent);
55+
Map claims = (Map) new JSONParser().parse(jsonContent);
5356
token = new Token(String.valueOf(claims.get(USER_NAME)));
5457
token.setExpiresOn(StringUtils.getInt(claims.get(EXPIRES), 0));
5558
token.set(EMAIL, String.valueOf(claims.get(EMAIL)));
5659
token.set(NAME, String.valueOf(claims.get(NAME)));
60+
token.set(UID_NUMBER, String.valueOf(claims.get(UID_NUMBER)));
5761
token.set(UID, String.valueOf(claims.get(UID)));
5862
token.set(ID_TOKEN, id_token);
5963

@@ -80,7 +84,8 @@ public UserInfo getUserInfo() {
8084
Token token = getAuthToken();
8185
if (token != null) {
8286
UserInfo user = new UserInfo();
83-
user.setLoginName(token.getId());
87+
//user.setLoginName(token.getId());
88+
user.setLoginName(token.get(UID));
8489
user.setEmail(token.get(EMAIL));
8590
String name = token.get(NAME) == null ? "" : token.get(NAME);
8691
String[] parts = name.split(" ");
@@ -94,11 +99,14 @@ public UserInfo getUserInfo() {
9499
}
95100

96101
public void setAuthCredential(HttpServiceInput inputs) {
102+
// // to test from a local machine, obtain temptoken and set it directly,
103+
// // you also need to set
104+
// String tempToken = "short token here";
105+
// inputs.setHeader("Authorization", "Bearer " + tempToken);
97106
Token token = getAuthToken();
98107
if (token != null && token.get(ID_TOKEN) != null) {
99108
if (SsoAdapter.requireAuthCredential(inputs.getRequestUrl(), reqAuthHosts)) {
100109
inputs.setHeader("Authorization", "Bearer " + token.get(ID_TOKEN));
101-
102110
}
103111
}
104112
}

src/suit/js/SUIT.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ var options = {
5959
value: 'https://ned.ipac.caltech.edu/tap/' },
6060
],
6161
defaultMaxrec: 50000
62-
}
62+
},
63+
workspace: {showOptions: true}
6364
};
6465

6566

0 commit comments

Comments
 (0)