-
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
3669be2
commit 62e1ad8
Showing
24 changed files
with
984 additions
and
35 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,69 @@ | ||
{{#if @data.form_data.authorization_needed}} | ||
<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 | ||
data-test-oidcAuthorize-heading | ||
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 | ||
data-test-oidcAuthorize-scopeDescription='{{sd}}' | ||
as |li| | ||
> | ||
<li.leftIcon @disabled={{true}}> | ||
<AkIcon @iconName='chevron-right' /> | ||
</li.leftIcon> | ||
|
||
<li.text @primaryText={{sd}} /> | ||
</akl.listItem> | ||
{{/each}} | ||
</AkList> | ||
</div> | ||
|
||
<AkDivider class='mb-3' /> | ||
|
||
<AkStack | ||
class='px-3' | ||
@alignItems='center' | ||
@justifyContent='space-between' | ||
@spacing='1.5' | ||
> | ||
<AkButton | ||
data-test-oidcAuthorize-cancelBtn | ||
class='w-full' | ||
@variant='outlined' | ||
@color='neutral' | ||
{{on 'click' (perform this.cancelAuthorization)}} | ||
@disabled={{this.oidc.authorizeOidcAppPermissions.isRunning}} | ||
> | ||
{{t 'cancel'}} | ||
</AkButton> | ||
|
||
<AkButton | ||
data-test-oidcAuthorize-authorizeBtn | ||
class='w-full' | ||
@disabled={{this.oidc.authorizeOidcAppPermissions.isRunning}} | ||
@loading={{this.allowAuthorization.isRunning}} | ||
{{on 'click' (perform this.allowAuthorization)}} | ||
> | ||
{{t 'authorize'}} | ||
</AkButton> | ||
</AkStack> | ||
</div> | ||
</div> | ||
</div> | ||
{{/if}} |
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,63 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
import OidcService, { OidcAuthorizationResponse } from 'irene/services/oidc'; | ||
|
||
export interface OidcAuthorizeSignature { | ||
Args: { | ||
token?: string; | ||
data?: OidcAuthorizationResponse; | ||
}; | ||
} | ||
|
||
export default class OidcAuthorizeComponent extends Component<OidcAuthorizeSignature> { | ||
@service declare oidc: OidcService; | ||
|
||
constructor(owner: unknown, args: OidcAuthorizeSignature['Args']) { | ||
super(owner, args); | ||
|
||
this.authorizeIfNoUserAuthorizationNeeded(); | ||
} | ||
|
||
get applicationName() { | ||
return this.args.data?.form_data?.application_name; | ||
} | ||
|
||
get scopeDescriptions() { | ||
return this.args.data?.form_data?.scopes_descriptions; | ||
} | ||
|
||
authorizeIfNoUserAuthorizationNeeded() { | ||
const formData = this.args.data?.form_data; | ||
|
||
const authorizationNotNeeded = | ||
typeof formData !== 'undefined' && | ||
formData !== null && | ||
!formData.authorization_needed; | ||
|
||
if (authorizationNotNeeded) { | ||
this.oidc.authorizeOidcAppPermissions.perform(this.args.token as string); | ||
} | ||
} | ||
|
||
cancelAuthorization = task(async () => { | ||
await this.oidc.authorizeOidcAppPermissions.perform( | ||
this.args.token as string, | ||
false | ||
); | ||
}); | ||
|
||
allowAuthorization = task(async () => { | ||
await this.oidc.authorizeOidcAppPermissions.perform( | ||
this.args.token as string, | ||
true | ||
); | ||
}); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export interface OidcError { | ||
statusCode: number; | ||
code?: string; | ||
description?: string; | ||
} | ||
|
||
export default class OidcErrorController extends Controller { | ||
@tracked error: OidcError | null = null; | ||
} |
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'] | ||
); | ||
} | ||
} | ||
} |
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,17 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import OidcService from 'irene/services/oidc'; | ||
|
||
export default class OidcAuthorizeRoute extends Route { | ||
@service declare oidc: OidcService; | ||
|
||
queryParams = { | ||
oidc_token: { | ||
refreshModel: true, | ||
}, | ||
}; | ||
|
||
async model({ oidc_token }: { oidc_token: string }) { | ||
return await this.oidc.fetchOidcAuthorizationDataOrRedirect(oidc_token); | ||
} | ||
} |
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,9 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
import OidcErrorController, { OidcError } from 'irene/controllers/oidc/error'; | ||
|
||
export default class OidcErrorRoute extends Route { | ||
setupController(controller: OidcErrorController, error: OidcError) { | ||
controller.set('error', error); | ||
} | ||
} |
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,17 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import OidcService from 'irene/services/oidc'; | ||
|
||
export default class OidcRedirectRoute extends Route { | ||
@service declare oidc: OidcService; | ||
|
||
queryParams = { | ||
oidc_token: { | ||
refreshModel: true, | ||
}, | ||
}; | ||
|
||
async model({ oidc_token }: { oidc_token: string }) { | ||
await this.oidc.validateOidcTokenOrRedirect(oidc_token); | ||
} | ||
} |
Oops, something went wrong.