Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
8b63d4eb
Commit
8b63d4eb
authored
5 years ago
by
Bekerle, Patrizio
Committed by
Reiter, Christoph
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Merge branch 'master' of gitlab.tugraz.at:VPU/WebComponents/Auth
# Conflicts: # vpu-auth.js
parent
0033de9e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/auth/README.md
+15
-10
15 additions, 10 deletions
packages/auth/README.md
packages/auth/rollup.config.js
+4
-2
4 additions, 2 deletions
packages/auth/rollup.config.js
packages/auth/vpu-auth.js
+6
-6
6 additions, 6 deletions
packages/auth/vpu-auth.js
with
25 additions
and
18 deletions
packages/auth/README.md
+
15
−
10
View file @
8b63d4eb
...
@@ -2,21 +2,29 @@
...
@@ -2,21 +2,29 @@
[
GitLab Repository
](
https://gitlab.tugraz.at/VPU/WebComponents/Auth
)
[
GitLab Repository
](
https://gitlab.tugraz.at/VPU/WebComponents/Auth
)
## Usage
```
html
<vpu-auth
client-id=
"my-client-id"
></vpu-auth>
```
## Attributes
## Attributes
-
`client-id`
(mandatory): set the client id that you have setup on your Keycloak server
-
`client-id`
(mandatory): set the client id that you have setup on your Keycloak server
-
example
`<vpu-auth client-id="my-
dev-
client-id"></vpu-auth>`
-
example
`<vpu-auth client-id="my-client-id"></vpu-auth>`
-
`lang`
(optional, default:
`de`
): set to
`de`
or
`en`
for German or English
-
`lang`
(optional, default:
`de`
): set to
`de`
or
`en`
for German or English
-
example
`<vpu-auth lang="de" client-id="my-
dev-
client-id"></vpu-auth>`
-
example
`<vpu-auth lang="de" client-id="my-client-id"></vpu-auth>`
-
`load-person`
(optional, default: off): if enabled the logged in user will also be loaded as
`Person`
-
`load-person`
(optional, default: off): if enabled the logged in user will also be loaded as
`Person`
in the
`window.VPUPerson`
variable
in the
`window.VPUPerson`
variable
-
example
`<vpu-auth client-id="my-
dev-
client-id" load-person></vpu-auth>`
-
example
`<vpu-auth client-id="my-client-id" load-person></vpu-auth>`
-
`force-login`
(optional, default: off): if enabled a login will be forced, there never will be a login button
-
`force-login`
(optional, default: off): if enabled a login will be forced, there never will be a login button
-
example
`<vpu-auth client-id="my-
dev-
client-id" force-login></vpu-auth>`
-
example
`<vpu-auth client-id="my-client-id" force-login></vpu-auth>`
## Events
## Events
to listen to
TODO
-
`vpu-auth-init`
: Keycloak init event - happens once
-
`vpu-auth-person-init`
: Keycloak person init event - the person entity was loaded from the server
-
`vpu-auth-keycloak-data-update`
: Keycloak data was updated - happens for example every time after a token refresh
## Local development
## Local development
...
@@ -33,11 +41,8 @@ npm run setup
...
@@ -33,11 +41,8 @@ npm run setup
# install dependencies
# install dependencies
npm
install
npm
install
# constantly build
s
dist/bundle.js
# constantly build dist/bundle.js
and run a local web-server on port 8002
npm run watch-local
npm run watch-local
# run local webserver
cd
dist
;
php
-S
localhost:8002
```
```
Jump to
<http://localhost:8002>
and you should get a Single Sign On login page.
Jump to
<http://localhost:8002>
and you should get a Single Sign On login page.
This diff is collapsed.
Click to expand it.
packages/auth/rollup.config.js
+
4
−
2
View file @
8b63d4eb
...
@@ -5,6 +5,7 @@ import copy from 'rollup-plugin-copy';
...
@@ -5,6 +5,7 @@ import copy from 'rollup-plugin-copy';
import
{
terser
}
from
"
rollup-plugin-terser
"
;
import
{
terser
}
from
"
rollup-plugin-terser
"
;
import
json
from
'
rollup-plugin-json
'
;
import
json
from
'
rollup-plugin-json
'
;
import
replace
from
"
rollup-plugin-replace
"
;
import
replace
from
"
rollup-plugin-replace
"
;
import
serve
from
'
rollup-plugin-serve
'
;
const
build
=
(
typeof
process
.
env
.
BUILD
!==
'
undefined
'
)
?
process
.
env
.
BUILD
:
'
local
'
;
const
build
=
(
typeof
process
.
env
.
BUILD
!==
'
undefined
'
)
?
process
.
env
.
BUILD
:
'
local
'
;
console
.
log
(
"
build:
"
+
build
);
console
.
log
(
"
build:
"
+
build
);
...
@@ -27,7 +28,7 @@ export default {
...
@@ -27,7 +28,7 @@ export default {
minimize
:
false
,
minimize
:
false
,
plugins
:
[]
plugins
:
[]
}),
}),
terser
()
,
(
build
!==
'
local
'
)
?
terser
()
:
false
,
copy
({
copy
({
targets
:
[
targets
:
[
'
index.html
'
,
'
index.html
'
,
...
@@ -36,6 +37,7 @@ export default {
...
@@ -36,6 +37,7 @@ export default {
'
node_modules/@webcomponents/webcomponentsjs/bundles
'
,
'
node_modules/@webcomponents/webcomponentsjs/bundles
'
,
],
],
outputFolder
:
'
dist
'
outputFolder
:
'
dist
'
})
}),
(
process
.
env
.
ROLLUP_WATCH
===
'
true
'
)
?
serve
({
contentBase
:
'
dist
'
,
host
:
'
127.0.0.1
'
,
port
:
8002
})
:
false
]
]
};
};
This diff is collapsed.
Click to expand it.
packages/auth/vpu-auth.js
+
6
−
6
View file @
8b63d4eb
...
@@ -59,16 +59,16 @@ class VPUAuth extends LitElement {
...
@@ -59,16 +59,16 @@ class VPUAuth extends LitElement {
// load Keycloak if we want to force the login or if we were redirected from the Keycloak login page
// load Keycloak if we want to force the login or if we were redirected from the Keycloak login page
if
(
this
.
forceLogin
||
(
href
.
indexOf
(
'
#state=
'
)
>
0
&&
href
.
indexOf
(
'
&session_state=
'
)
>
0
))
{
if
(
this
.
forceLogin
||
(
href
.
indexOf
(
'
#state=
'
)
>
0
&&
href
.
indexOf
(
'
&session_state=
'
)
>
0
))
{
this
.
loadKey
C
loak
();
this
.
loadKey
c
loak
();
}
}
this
.
updateComplete
.
then
(()
=>
{
this
.
updateComplete
.
then
(()
=>
{
});
});
}
}
loadKey
C
loak
()
{
loadKey
c
loak
()
{
const
that
=
this
;
const
that
=
this
;
console
.
log
(
"
loadKey
C
loak
"
);
console
.
log
(
"
loadKey
c
loak
"
);
if
(
!
this
.
keyCloakInitCalled
)
{
if
(
!
this
.
keyCloakInitCalled
)
{
// inject Keycloak javascript file
// inject Keycloak javascript file
...
@@ -142,7 +142,7 @@ class VPUAuth extends LitElement {
...
@@ -142,7 +142,7 @@ class VPUAuth extends LitElement {
}
}
login
(
e
)
{
login
(
e
)
{
this
.
loadKey
C
loak
();
this
.
loadKey
c
loak
();
}
}
logout
(
e
)
{
logout
(
e
)
{
...
@@ -201,7 +201,7 @@ class VPUAuth extends LitElement {
...
@@ -201,7 +201,7 @@ class VPUAuth extends LitElement {
#logout-block { display: none }
#logout-block { display: none }
</style>
</style>
<div id="logout-block" class="columns is-vcentered"
"
>
<div id="logout-block" class="columns is-vcentered">
<div class="column">
<div class="column">
${
this
.
name
}
${
this
.
name
}
</div>
</div>
...
@@ -210,7 +210,7 @@ class VPUAuth extends LitElement {
...
@@ -210,7 +210,7 @@ class VPUAuth extends LitElement {
</div>
</div>
</div>
</div>
<div id="login-block" class="columns is-vcentered"
"
>
<div id="login-block" class="columns is-vcentered">
<div class="column">
<div class="column">
<button id="login-button" @click="
${
this
.
login
}
" class="button">
${
i18n
.
t
(
'
login
'
)}
</button>
<button id="login-button" @click="
${
this
.
login
}
" class="button">
${
i18n
.
t
(
'
login
'
)}
</button>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment