Commit 6eaeaaa3 by Shwetha GS

ATLAS-853 User's name to be mentioned in the top user drop down (saqeeb.s via shwethags)

parent 606690c4
......@@ -103,6 +103,8 @@ public class AtlasAuthorizationUtils {
String api = getApi(contextPath);
if (api.startsWith("types")) {
resourceTypes.add(AtlasResourceTypes.TYPE);
} else if (api.startsWith("admin") && contextPath.contains("/session")) {
resourceTypes.add(AtlasResourceTypes.UNKNOWN);
} else if ((api.startsWith("discovery") && contextPath.contains("/gremlin")) || api.startsWith("admin")
|| api.startsWith("graph")) {
resourceTypes.add(AtlasResourceTypes.OPERATION);
......
......@@ -14,12 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<ol class="breadcrumb col-md-6">
</ol>
<header class="clearfix">
<div class="btn-group pull-right">
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa fa-user user-circle"></i></a>
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><span class="userName"></span><i class="fa fa-user user-circle"></i></a>
<ul class="dropdown-menu">
<!-- <li><a href="#">Edit Profile</a></li>
<li><a href="#">Change Password</a></li> -->
......
......@@ -16,14 +16,16 @@
-->
<header class="clearfix">
<div class="btn-group pull-right">
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa fa-user user-circle "></i></a>
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><span class="userName"></span><i class="fa fa-user user-circle "></i></a>
<ul class="dropdown-menu">
<!-- <li><a href="#">Edit Profile</a></li>
<li><a href="#">Change Password</a></li> -->
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
<li><a target="_blank" href="https://cwiki.apache.org/confluence/display/ATLAS/Atlas+Home">Help</a></li>
<li role="separator" class="divider"></li>
<li><a href="logout.html"> <i class="fa fa-sign-out"></i> Logout</a></li>
<li>
<a href="logout.html"> <i class="fa fa-sign-out"></i> Logout</a>
</li>
</ul>
</div>
</header>
......@@ -170,5 +170,17 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages'], function(r
});
return table;
}
CommonViewFunction.userDataFetch = function(options) {
if (options.url) {
$.ajax({
url: options.url,
success: function(response) {
if (options.callback) {
options.callback(response);
}
}
});
}
}
return CommonViewFunction;
});
......@@ -41,6 +41,10 @@ define(['require'], function(require) {
TAG_ADD: "Tag Added",
TAG_DELETE: "Tag Deleted"
}
Globals.userLogedIn = {
status: false,
response: {}
}
return Globals;
});
......@@ -17,8 +17,10 @@
*/
define(['require',
'hbs!tmpl/business_catalog/BusinessCatalogHeader'
], function(require, tmpl) {
'hbs!tmpl/business_catalog/BusinessCatalogHeader',
'utils/CommonViewFunction',
'utils/Globals'
], function(require, tmpl, CommonViewFunction, Globals) {
'use strict';
var BusinessCatalogHeader = Marionette.LayoutView.extend({
......@@ -36,7 +38,20 @@ define(['require',
* @return {[type]} [description]
*/
render: function() {
var that = this;
$(this.el).html(this.template());
if (!Globals.userLogedIn.status) {
CommonViewFunction.userDataFetch({
url: Globals.baseURL + "/api/atlas/admin/session",
callback: function(response) {
that.$('.userName').html(response.userName);
Globals.userLogedIn.status = true;
Globals.userLogedIn.response = response;
}
});
} else {
that.$('.userName').html(Globals.userLogedIn.response.userName);
}
var that = this;
if (this.url) {
var t = [];
......
......@@ -18,7 +18,9 @@
define(['require',
'hbs!tmpl/site/header',
], function(require, tmpl) {
'utils/CommonViewFunction',
'utils/Globals'
], function(require, tmpl, CommonViewFunction, Globals) {
'use strict';
var Header = Marionette.LayoutView.extend({
......@@ -26,7 +28,21 @@ define(['require',
regions: {},
events: {},
initialize: function(options) {},
onRender: function() {}
onRender: function() {
var that = this;
if (!Globals.userLogedIn.status) {
CommonViewFunction.userDataFetch({
url: Globals.baseURL + "/api/atlas/admin/session",
callback: function(response) {
that.$('.userName').html(response.userName);
Globals.userLogedIn.status = true;
Globals.userLogedIn.response = response;
}
});
} else {
that.$('.userName').html(Globals.userLogedIn.response.userName);
}
},
});
return Header;
});
......@@ -22,6 +22,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
ATLAS-853 User's name to be mentioned in the top user drop down (saqeeb.s via shwethags)
ATLAS-867 Excessive logs: default log level should be set to 'info'; currently it is 'debug' (svimal2106 via sumasai )
ATLAS-870 Add search feature while associating Tags / Terms with entity. (Kalyanikashikar via yhemanth)
ATLAS-865 Edit description functionality for Tags (kevalbhatt18 via yhemanth)
......
......@@ -104,7 +104,7 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
userName = String.valueOf(auth.getPrincipal());
userName = auth.getName();
Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
for (GrantedAuthority c : authorities) {
groups.add(c.getAuthority());
......
......@@ -18,7 +18,18 @@
package org.apache.atlas.web.resources;
import com.google.inject.Inject;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.web.service.ServiceState;
import org.apache.atlas.web.util.Servlets;
......@@ -27,14 +38,11 @@ import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.google.inject.Inject;
/**
* Jersey Resource for admin operations.
......@@ -121,4 +129,30 @@ public class AdminResource {
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
}
}
@GET
@Path("session")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getUserProfile() {
JSONObject responseData = new JSONObject();
try {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String userName = null;
Set<String> groups = new HashSet<String>();
if (auth != null) {
userName = auth.getName();
Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
for (GrantedAuthority c : authorities) {
groups.add(c.getAuthority());
}
}
responseData.put("userName", userName);
responseData.put("groups", groups);
Response response = Response.ok(responseData).build();
return response;
} catch (JSONException e) {
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment