forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Václav Muzikář <[email protected]>
- Loading branch information
Showing
8 changed files
with
53 additions
and
27 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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
import { Banner, Flex, FlexItem } from "@patternfly/react-core"; | ||
import { ExclamationTriangleIcon } from "@patternfly/react-icons"; | ||
import { useWhoAmI } from "./context/whoami/WhoAmI"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
const WarnBanner = (msg: string) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Banner screenReaderText={t(msg)} variant="gold" isSticky> | ||
<Flex spaceItems={{ default: "spaceItemsSm" }}> | ||
<FlexItem> | ||
<ExclamationTriangleIcon /> | ||
</FlexItem> | ||
<FlexItem>{t(msg)}</FlexItem> | ||
</Flex> | ||
</Banner> | ||
); | ||
}; | ||
|
||
export const Banners = () => { | ||
const { whoAmI } = useWhoAmI(); | ||
|
||
if (whoAmI.isTemporary()) return WarnBanner("loggedInAsTempAdminUser"); | ||
// more banners in the future? | ||
}; |
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 |
---|---|---|
|
@@ -68,6 +68,8 @@ | |
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.keycloak.services.managers.ApplianceBootstrap.TEMP_ADMIN_ATTR_NAME; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
|
@@ -98,6 +100,7 @@ public static class WhoAmI { | |
protected String realm; | ||
protected String displayName; | ||
protected Locale locale; | ||
protected boolean isTemporary; | ||
|
||
@JsonProperty("createRealm") | ||
protected boolean createRealm; | ||
|
@@ -107,13 +110,14 @@ public static class WhoAmI { | |
public WhoAmI() { | ||
} | ||
|
||
public WhoAmI(String userId, String realm, String displayName, boolean createRealm, Map<String, Set<String>> realmAccess, Locale locale) { | ||
public WhoAmI(String userId, String realm, String displayName, boolean createRealm, Map<String, Set<String>> realmAccess, Locale locale, boolean isTemporary) { | ||
this.userId = userId; | ||
this.realm = realm; | ||
this.displayName = displayName; | ||
this.createRealm = createRealm; | ||
this.realmAccess = realmAccess; | ||
this.locale = locale; | ||
this.isTemporary = isTemporary; | ||
} | ||
|
||
public String getUserId() { | ||
|
@@ -168,6 +172,14 @@ public void setLocale(Locale locale) { | |
public String getLocaleLanguageTag() { | ||
return locale != null ? locale.toLanguageTag() : null; | ||
} | ||
|
||
public boolean isTemporary() { | ||
return isTemporary; | ||
} | ||
|
||
public void setTemporary(boolean temporary) { | ||
isTemporary = temporary; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -269,7 +281,7 @@ public Response whoAmI(@QueryParam("currentRealm") String currentRealm) { | |
.allowedOrigins(authResult.getToken()) | ||
.allowedMethods("GET") | ||
.auth() | ||
.add(Response.ok(new WhoAmI(user.getId(), realm.getName(), displayName, createRealm, realmAccess, locale))); | ||
.add(Response.ok(new WhoAmI(user.getId(), realm.getName(), displayName, createRealm, realmAccess, locale, Boolean.parseBoolean(user.getFirstAttribute(TEMP_ADMIN_ATTR_NAME))))); | ||
} | ||
|
||
private void addRealmAccess(RealmModel realm, UserModel user, Map<String, Set<String>> realmAdminAccess) { | ||
|