-
Notifications
You must be signed in to change notification settings - Fork 4
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 #370 from TeskaLabs/feature/implement-tenant-sessions
Implement tenant sessions
- Loading branch information
Showing
14 changed files
with
184 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ module.exports = { | |
MOCK_USERINFO: { | ||
"email": "[email protected]", | ||
"phone_number": "0123456789", | ||
"preferred_username": "Test", | ||
"username": "Test", | ||
"resources": ["test:testy:read"], | ||
"roles": ["default/Gringo"], | ||
"sub": "tst:123456789", | ||
|
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ Developers can define as many properties they want to simulate e.g. features/ite | |
|
||
To successfuly simulate the `userinfo`, some properties should be set: | ||
|
||
* `preffered_username` - username | ||
* `username` - username | ||
* `tenants` - list of tenants | ||
* `roles` - list of roles | ||
* `resources` - list of resources | ||
|
@@ -54,7 +54,7 @@ module.exports = { | |
MOCK_USERINFO: { | ||
"email": "[email protected]", | ||
"phone_number": "0123456789", | ||
"preferred_username": "Test", | ||
"username": "Test", | ||
"resources": ["test:testy:read"], | ||
"roles": ["default/Gringo"], | ||
"sub": "tst:123456789", | ||
|
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,81 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { locationReplace } from 'asab-webui'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { | ||
Card, CardHeader, CardBody, CardTitle, | ||
Button, Input, Label | ||
} from 'reactstrap'; | ||
|
||
import "./access.scss"; | ||
|
||
function AccessDeniedCard(props) { | ||
const { t } = useTranslation(); | ||
const [ accessDenied, setAccessDenied ] = useState(false); | ||
const [ deniedTenant, setDeniedTenant ] = useState(""); | ||
|
||
useEffect(() => { | ||
var qs = new URLSearchParams(window.location.search); | ||
const errorType = qs.get('error'); | ||
if ((errorType != undefined) && errorType.includes("access_denied")) { | ||
const tenantParameter = qs.get('tenant'); | ||
setAccessDenied(true); | ||
setDeniedTenant(tenantParameter); | ||
} | ||
}, []) | ||
|
||
/* | ||
We can't use logout/redirection to login via /openidconnect/logout, | ||
since we dont have a oauth token here (access denied) | ||
*/ | ||
const continueToLogin = async () => { | ||
const SeaCatAuthAPI = props.app.axiosCreate('seacat_auth'); | ||
let response; | ||
try { | ||
// Use public logout | ||
response = await SeaCatAuthAPI.put('/public/logout'); | ||
} catch (err) { | ||
console.error(err); | ||
props.app.addAlert("danger", t("AccessDeniedCard|Silly as it sounds, the logout failed")); | ||
} | ||
await locationReplace(`${window.location.pathname}`); | ||
} | ||
|
||
return ( | ||
props.app.Services.TenantService && | ||
props.app.Modules.filter(obj => obj.Name === "AuthModule").length > 0 && | ||
(accessDenied == true) ? | ||
<div className="access-denied-wrapper"> | ||
<Card className="access-denied-card shadow"> | ||
<CardHeader className="text-center border-bottom card-header-login"> | ||
<div className="card-header-title"> | ||
<CardTitle className="text-primary mb-0" tag="h2"> | ||
{t("AccessDeniedCard|Access denied")} | ||
</CardTitle> | ||
</div> | ||
</CardHeader> | ||
<CardBody> | ||
<p className="text-center"> | ||
{t("AccessDeniedCard|Please contact application administrator for assigning appropriate access rights.")} | ||
</p> | ||
{deniedTenant && | ||
<p className="text-center tenant-text"> | ||
<span>Tenant: </span>{deniedTenant} | ||
</p>} | ||
<Button | ||
className="justify-content-center" | ||
block | ||
color="primary" | ||
onClick={() => {continueToLogin()}} | ||
> | ||
{t("AccessDeniedCard|Leave")} | ||
</Button> | ||
</CardBody> | ||
</Card> | ||
</div> | ||
: null | ||
); | ||
} | ||
|
||
export default AccessDeniedCard; |
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,32 @@ | ||
@import "~asab-webui/styles/constants/index.scss"; | ||
|
||
.access-denied-card { | ||
max-width: 650px; | ||
margin: 0 auto; | ||
float: none; | ||
margin-top: 1% !important; | ||
margin-bottom: -15% !important; | ||
background-color: $bg-color; | ||
z-index: 999; | ||
.card-body { | ||
p { | ||
margin-bottom: 8px; | ||
} | ||
}; | ||
.card-header-login { | ||
min-height: inherit !important; | ||
} | ||
} | ||
|
||
.access-denied-wrapper { | ||
display: inline-block; | ||
position: absolute; | ||
width: 100%; | ||
} | ||
|
||
.tenant-text { | ||
font-weight: 600; | ||
span { | ||
font-weight: initial; | ||
} | ||
} |
Oops, something went wrong.