[release] v0.6.0 - OpenID
This commit is contained in:
parent
1970f14eac
commit
1125569811
|
@ -44,9 +44,8 @@ const OpenID = () => {
|
||||||
const selfHostname = selfprotocol + (new URL(window.location.href).hostname) + (selfport ? ":" + selfport : "")
|
const selfHostname = selfprotocol + (new URL(window.location.href).hostname) + (selfport ? ":" + selfport : "")
|
||||||
|
|
||||||
const onchange = (e, scope) => {
|
const onchange = (e, scope) => {
|
||||||
console.log(scope)
|
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
setCheckedScopes([...checkedScopes,scope])
|
setCheckedScopes([...checkedScopes, scope])
|
||||||
} else {
|
} else {
|
||||||
setCheckedScopes(checkedScopes.filter((scope) => scope != scope))
|
setCheckedScopes(checkedScopes.filter((scope) => scope != scope))
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,21 @@ const checkHost = debounce((host, setHostError) => {
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
setHostError(err.message)
|
setHostError(err.message)
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
setHostError(null);
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
const RouteManagement = ({ routeConfig, routeNames, TargetContainer, noControls = false, lockTarget = false, title, setRouteConfig, submitButton = false, newRoute }) => {
|
const RouteManagement = ({ routeConfig, routeNames, TargetContainer, noControls = false, lockTarget = false, title, setRouteConfig, submitButton = false, newRoute }) => {
|
||||||
const [openModal, setOpenModal] = React.useState(false);
|
const [openModal, setOpenModal] = React.useState(false);
|
||||||
const [hostError, setHostError] = React.useState(null);
|
const [hostError, setHostError] = React.useState(null);
|
||||||
|
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if(routeConfig && routeConfig.Host) {
|
||||||
|
checkHost(routeConfig.Host, setHostError);
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
return <div style={{ maxWidth: '1000px', width: '100%', margin: '', position: 'relative' }}>
|
return <div style={{ maxWidth: '1000px', width: '100%', margin: '', position: 'relative' }}>
|
||||||
<RestartModal openModal={openModal} setOpenModal={setOpenModal} />
|
<RestartModal openModal={openModal} setOpenModal={setOpenModal} />
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,6 @@ export function CosmosContainerPicker({formik, nameOnly, lockTarget, TargetConta
|
||||||
})
|
})
|
||||||
setPortsOptions(portsTemp)
|
setPortsOptions(portsTemp)
|
||||||
|
|
||||||
console.log(targetResult)
|
|
||||||
|
|
||||||
if(targetResult.port == '') {
|
if(targetResult.port == '') {
|
||||||
targetResult.port = '80'
|
targetResult.port = '80'
|
||||||
|
|
||||||
|
@ -119,7 +117,6 @@ export function CosmosContainerPicker({formik, nameOnly, lockTarget, TargetConta
|
||||||
}
|
}
|
||||||
|
|
||||||
const onContainerChange = (newContainer) => {
|
const onContainerChange = (newContainer) => {
|
||||||
console.log(newContainer)
|
|
||||||
if(loading) return;
|
if(loading) return;
|
||||||
targetResult.container = newContainer.Names[0]
|
targetResult.container = newContainer.Names[0]
|
||||||
targetResult.containerObject = newContainer
|
targetResult.containerObject = newContainer
|
||||||
|
|
|
@ -40,6 +40,9 @@ const debounce = (func, wait) => {
|
||||||
setHostError(err.message)
|
setHostError(err.message)
|
||||||
setHostIp(null)
|
setHostIp(null)
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
setHostError(null);
|
||||||
|
setHostIp(null);
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const OpenIdEditModal = ({ clientId, openNewModal, setOpenNewModal, config, onSu
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientConfig = Object.values(config.OpenIDClients).find((c) => c.id === clientId);
|
const clientConfig = config.OpenIDClients && Object.values(config.OpenIDClients).find((c) => c.id === clientId);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<RestartModal openModal={openRestartModal} setOpenModal={setOpenRestartModal} />
|
<RestartModal openModal={openRestartModal} setOpenModal={setOpenRestartModal} />
|
||||||
|
|
|
@ -115,7 +115,6 @@ const OpenIdList = () => {
|
||||||
const generateNewSecret = (clientIdToUpdate) => {
|
const generateNewSecret = (clientIdToUpdate) => {
|
||||||
let newSecret = Math.random().toString(36).substring(2, 24) + Math.random().toString(36).substring(2, 15);
|
let newSecret = Math.random().toString(36).substring(2, 24) + Math.random().toString(36).substring(2, 15);
|
||||||
let encryptedSecret = bcrypt.hashSync(newSecret, 10);
|
let encryptedSecret = bcrypt.hashSync(newSecret, 10);
|
||||||
console.log(newSecret, encryptedSecret)
|
|
||||||
let index = clients.findIndex((r) => r.id === clientIdToUpdate);
|
let index = clients.findIndex((r) => r.id === clientIdToUpdate);
|
||||||
clients[index].secret = encryptedSecret;
|
clients[index].secret = encryptedSecret;
|
||||||
save(updateRoutes(clients));
|
save(updateRoutes(clients));
|
||||||
|
@ -181,6 +180,11 @@ const OpenIdList = () => {
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>}
|
</Dialog>}
|
||||||
|
|
||||||
|
|
||||||
|
<Alert severity="warning" icon={<WarningOutlined />}>
|
||||||
|
This is an experimental feature. It is recommended to use with caution. Please report any issue you find!
|
||||||
|
</Alert>
|
||||||
|
|
||||||
{clients && <PrettyTableView
|
{clients && <PrettyTableView
|
||||||
data={clients}
|
data={clients}
|
||||||
getKey={(r) => r.id}
|
getKey={(r) => r.id}
|
||||||
|
|
|
@ -240,7 +240,7 @@ const DockerComposeImport = ({ refresh }) => {
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
{step === 0 && <Stack spacing={2}>
|
{step === 0 && <Stack spacing={2}>
|
||||||
<Alert severity="warning" icon={<WarningOutlined />}>
|
<Alert severity="warning" icon={<WarningOutlined />}>
|
||||||
This is a highly experimental feature. It is recommended to use with caution.
|
This is an experimental feature. It is recommended to use with caution. Please report any issue you find!
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<UploadButtons
|
<UploadButtons
|
||||||
|
|
|
@ -109,8 +109,6 @@ const NewDockerServiceForm = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
console.log(containerInfo)
|
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<Stack direction="row" spacing={1} alignItems="center">
|
<Stack direction="row" spacing={1} alignItems="center">
|
||||||
|
@ -269,7 +267,6 @@ const NewDockerServiceForm = () => {
|
||||||
title: 'Storage',
|
title: 'Storage',
|
||||||
disabled: maxTab < 1,
|
disabled: maxTab < 1,
|
||||||
children: <Stack spacing={2}><VolumeContainerSetup newContainer containerInfo={containerInfo} OnChange={(values) => {
|
children: <Stack spacing={2}><VolumeContainerSetup newContainer containerInfo={containerInfo} OnChange={(values) => {
|
||||||
console.log(values)
|
|
||||||
const newValues = {
|
const newValues = {
|
||||||
...containerInfo,
|
...containerInfo,
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.6.0-unstable2",
|
"version": "0.6.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -46,7 +46,7 @@ func Init() {
|
||||||
ID: client.ID,
|
ID: client.ID,
|
||||||
Secret: []byte(client.Secret),
|
Secret: []byte(client.Secret),
|
||||||
RedirectURIs: []string{client.Redirect},
|
RedirectURIs: []string{client.Redirect},
|
||||||
Scopes: []string{"openid", "email"},
|
Scopes: []string{"openid", "email", "profile", "offline", "roles", "groups", "address", "phone", "role"},
|
||||||
ResponseTypes: []string{"id_token", "code", "token", "id_token token", "code id_token", "code token", "code id_token token"},
|
ResponseTypes: []string{"id_token", "code", "token", "id_token token", "code id_token", "code token", "code id_token token"},
|
||||||
GrantTypes: []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
|
GrantTypes: []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ func newSession(user string, req *http.Request) *openid.DefaultSession {
|
||||||
Claims: &jwt.IDTokenClaims{
|
Claims: &jwt.IDTokenClaims{
|
||||||
Issuer: hostname,
|
Issuer: hostname,
|
||||||
Subject: user,
|
Subject: user,
|
||||||
// Audience: []string{"https://my-client.my-application.com"},
|
|
||||||
ExpiresAt: time.Now().Add(time.Hour * 6),
|
ExpiresAt: time.Now().Add(time.Hour * 6),
|
||||||
IssuedAt: time.Now(),
|
IssuedAt: time.Now(),
|
||||||
RequestedAt: time.Now(),
|
RequestedAt: time.Now(),
|
||||||
|
|
|
@ -42,6 +42,7 @@ func authEndpoint(rw http.ResponseWriter, req *http.Request) {
|
||||||
// Now we need to get a response. This is the place where the AuthorizeEndpointHandlers kick in and start processing the request.
|
// Now we need to get a response. This is the place where the AuthorizeEndpointHandlers kick in and start processing the request.
|
||||||
// NewAuthorizeResponse is capable of running multiple response type handlers which in turn enables this library
|
// NewAuthorizeResponse is capable of running multiple response type handlers which in turn enables this library
|
||||||
// to support open id connect.
|
// to support open id connect.
|
||||||
|
|
||||||
response, err := oauth2.NewAuthorizeResponse(ctx, ar, mySessionData)
|
response, err := oauth2.NewAuthorizeResponse(ctx, ar, mySessionData)
|
||||||
|
|
||||||
// Catch any errors, e.g.:
|
// Catch any errors, e.g.:
|
||||||
|
|
|
@ -16,6 +16,7 @@ type oidcUser struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
|
Role string `json:"role"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Subject string `json:"sub"`
|
Subject string `json:"sub"`
|
||||||
IssuedAt int64 `json:"iat"`
|
IssuedAt int64 `json:"iat"`
|
||||||
|
@ -82,6 +83,12 @@ func userInfosEndpoint(rw http.ResponseWriter, req *http.Request) {
|
||||||
if ar.GetGrantedScopes().Has("email") {
|
if ar.GetGrantedScopes().Has("email") {
|
||||||
baseToken.Email = user.Email
|
baseToken.Email = user.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Role == utils.ADMIN {
|
||||||
|
baseToken.Role = "admin"
|
||||||
|
} else {
|
||||||
|
baseToken.Role = "user"
|
||||||
|
}
|
||||||
|
|
||||||
json.NewEncoder(rw).Encode(baseToken)
|
json.NewEncoder(rw).Encode(baseToken)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue