-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b97d4d
commit 8de8066
Showing
13 changed files
with
403 additions
and
30 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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<div local-class='oidc-authorize-root'> | ||
<div local-class='oidc-authorize-container'> | ||
<div class='mb-6'> | ||
<AuthAssets /> | ||
</div> | ||
|
||
<div class='py-3' local-class='oidc-authorize-card'> | ||
<AkTypography class='px-3' @variant='h6'> | ||
{{t | ||
'oidcModule.permissionHeading' | ||
applicationName=this.applicationName | ||
}} | ||
</AkTypography> | ||
|
||
<div class='py-1 px-3'> | ||
<AkList as |akl|> | ||
{{#each this.scopeDescriptions as |sd|}} | ||
<akl.listItem as |li|> | ||
<li.leftIcon @disabled={{true}}> | ||
<AkIcon @iconName='chevron-right' /> | ||
</li.leftIcon> | ||
|
||
<li.text @primaryText={{sd}} /> | ||
</akl.listItem> | ||
{{/each}} | ||
</AkList> | ||
</div> | ||
|
||
<AkDivider /> | ||
|
||
<AkStack | ||
class='p-3' | ||
@alignItems='center' | ||
@justifyContent='space-between' | ||
@spacing='1.5' | ||
> | ||
<AkButton | ||
class='w-full' | ||
@variant='outlined' | ||
@color='neutral' | ||
@disabled={{this.authorizeOidc.isRunning}} | ||
> | ||
{{t 'cancel'}} | ||
</AkButton> | ||
|
||
<AkButton | ||
class='w-full' | ||
@loading={{this.authorizeOidc.isRunning}} | ||
{{on 'click' (perform this.authorizeOidc)}} | ||
> | ||
{{t 'authorize'}} | ||
</AkButton> | ||
</AkStack> | ||
|
||
<AkStack | ||
@direction='column' | ||
@alignItems='center' | ||
@justifyContent='center' | ||
@spacing='0.5' | ||
> | ||
<AkTypography @color='textSecondary' @variant='body3'> | ||
{{t 'oidcModule.authorizeRedirectText'}} | ||
</AkTypography> | ||
|
||
<AkTypography @variant='body3'> | ||
{{this.redirectUrl}} | ||
</AkTypography> | ||
</AkStack> | ||
</div> | ||
</div> | ||
</div> |
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,22 @@ | ||
.oidc-authorize-root { | ||
width: 100%; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
background-color: var(--oidc-authorize-container-background-color); | ||
overflow: auto; | ||
padding: 3em; | ||
box-sizing: border-box; | ||
|
||
.oidc-authorize-container { | ||
margin: auto; | ||
} | ||
|
||
.oidc-authorize-card { | ||
width: 360px; | ||
border-radius: 4px; | ||
background-color: var(--oidc-authorize-card-background-color); | ||
box-shadow: var(--oidc-authorize-card-box-shadow); | ||
border: 1px solid var(--oidc-authorize-card-border-color); | ||
} | ||
} |
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,67 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
import NetworkService from 'irene/services/network'; | ||
import { OidcAuthorizationResponse } from 'irene/routes/oidc/authorize'; | ||
|
||
interface OidcAuthorizeResult { | ||
valid: boolean; | ||
redirect_url: null | string; | ||
error: null | { | ||
code: string; | ||
description: string; | ||
}; | ||
} | ||
|
||
export interface OidcAuthorizeSignature { | ||
Args: { | ||
token?: string; | ||
data?: OidcAuthorizationResponse; | ||
}; | ||
} | ||
|
||
export default class OidcAuthorizeComponent extends Component<OidcAuthorizeSignature> { | ||
@service declare network: NetworkService; | ||
@service('notifications') declare notify: NotificationService; | ||
@service('browser/window') declare window: Window; | ||
|
||
oidcAuthorizationEndpoint = '/api/v2/oidc/authorization/authorize'; | ||
|
||
get applicationName() { | ||
return this.args.data?.form_data?.application_name; | ||
} | ||
|
||
get scopeDescriptions() { | ||
return this.args.data?.form_data?.scope_description; | ||
} | ||
|
||
get redirectUrl() { | ||
return this.args.data?.validation_result?.redirect_url; | ||
} | ||
|
||
authorizeOidc = task(async () => { | ||
const res = await this.network.post(this.oidcAuthorizationEndpoint, { | ||
oidc_token: this.args.token, | ||
allow: true, | ||
}); | ||
|
||
const data = (await res.json()) as OidcAuthorizeResult; | ||
|
||
if (data.error) { | ||
this.notify.error(data.error.description); | ||
|
||
return; | ||
} | ||
|
||
if (data.valid && data.redirect_url) { | ||
this.window.location.href = data.redirect_url; | ||
} | ||
}); | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
OidcAuthorize: typeof OidcAuthorizeComponent; | ||
} | ||
} |
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,3 +1,18 @@ | ||
import Route from '@ember/routing/route'; | ||
import RouterService from '@ember/routing/router-service'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class LoginRoute extends Route {} | ||
import ENV from 'irene/config/environment'; | ||
|
||
export default class LoginRoute extends Route { | ||
@service declare session: any; | ||
@service declare router: RouterService; | ||
|
||
activate() { | ||
if (this.session.isAuthenticated) { | ||
this.router.transitionTo( | ||
ENV['ember-simple-auth']['routeIfAlreadyAuthenticated'] | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.