Skip to content

Commit 94c513a

Browse files
committed
feat(admin-ui): add uma resources function
1 parent d33a7db commit 94c513a

File tree

7 files changed

+53
-3
lines changed

7 files changed

+53
-3
lines changed

admin-ui/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
'generator-star-spacing': 'off',
4141
'space-in-parens': ['error', 'never'],
4242
'comma-spacing': ['error', { before: false, after: true }],
43-
indent: ['error', 2, { ignoredNodes: ['JSXElement'] }],
43+
indent: ['error', 2, { ignoredNodes: ['JSXElement'], "SwitchCase": 1 }],
4444
'react/jsx-indent': ['error', 2],
4545
'react/jsx-indent-props': ['error', 2],
4646
'react/display-name': [0, { ignoreTranspilerName: false }],

admin-ui/plugins/auth-server/components/Clients/ClientEditPage.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import ClientWizardForm from './ClientWizardForm'
33
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
44
import { useHistory } from 'react-router-dom'
55
import { connect } from 'react-redux'
6-
import { editClient } from 'Plugins/auth-server/redux/actions/OIDCActions'
6+
import { editClient, getUMAResourcesByClient } from 'Plugins/auth-server/redux/actions/OIDCActions'
77
import { getScopes } from 'Plugins/auth-server/redux/actions/ScopeActions'
88
import { getOidcDiscovery } from 'Redux/actions/OidcDiscoveryActions'
99
import { getScripts } from 'Redux/actions/InitActions'
1010
import { buildPayload } from 'Utils/PermChecker'
1111
import GluuAlert from 'Routes/Apps/Gluu/GluuAlert'
1212
import { useTranslation } from 'react-i18next'
13+
import isEmpty from 'lodash/isEmpty'
1314

1415
function ClientEditPage({
1516
clientData,
@@ -22,6 +23,7 @@ function ClientEditPage({
2223
oidcConfiguration,
2324
saveOperationFlag,
2425
errorInSaveOperationFlag,
26+
umaResources,
2527
}) {
2628
const userAction = {}
2729
const options = {}
@@ -37,6 +39,10 @@ function ClientEditPage({
3739
if (scripts.length < 1) {
3840
dispatch(getScripts(options))
3941
}
42+
console.log('umaResources', umaResources)
43+
if (isEmpty(umaResources)) {
44+
dispatch(getUMAResourcesByClient(clientData?.inum))
45+
}
4046
dispatch(getOidcDiscovery())
4147
}, [])
4248
useEffect(() => {
@@ -86,6 +92,7 @@ const mapStateToProps = (state) => {
8692
oidcConfiguration: state.oidcDiscoveryReducer.configuration,
8793
saveOperationFlag: state.oidcReducer.saveOperationFlag,
8894
errorInSaveOperationFlag: state.oidcReducer.errorInSaveOperationFlag,
95+
umaResources: state.oidcReducer.umaResources,
8996
}
9097
}
9198
export default connect(mapStateToProps)(ClientEditPage)

admin-ui/plugins/auth-server/redux/actions/OIDCActions.js

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
SET_CLIENT_ITEM,
1111
SET_VIEW,
1212
SEARCH_CLIENTS,
13+
GET_UMA_RESOURCES
1314
} from './types'
1415

1516
export const getOpenidClients = (action) => ({
@@ -65,3 +66,8 @@ export const viewOnly = (view) => ({
6566
type: SET_VIEW,
6667
payload: { view },
6768
})
69+
70+
export const getUMAResourcesByClient = (inum) => ({
71+
type: GET_UMA_RESOURCES,
72+
payload: { inum },
73+
})

admin-ui/plugins/auth-server/redux/actions/types.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const DELETE_CLIENT = 'DELETE_CLIENT'
3737
export const DELETE_CLIENT_RESPONSE = 'DELETE_CLIENT_RESPONSE'
3838
export const SET_CLIENT_ITEM = 'SET_CLIENT_ITEM'
3939
export const SET_VIEW = 'SET_VIEW'
40+
export const GET_UMA_RESOURCES = 'GET_UMA_RESOURCES'
4041

4142
// Attributes types
4243
export const GET_ATTRIBUTES = 'GET_ATTRIBUTES'

admin-ui/plugins/auth-server/redux/api/OIDCApi.js

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export default class OIDCApi {
3535
})
3636
}
3737

38+
getUMAResources = async (clientId) => {
39+
return new Promise((resolve, reject) => {
40+
this.api.getUMAResourcesByClient(clientId, (error, data) => {
41+
this.handleResponse(error, reject, resolve, data)
42+
})
43+
})
44+
}
45+
3846
handleResponse(error, reject, resolve, data) {
3947
if (error) {
4048
reject(error)

admin-ui/plugins/auth-server/redux/reducers/OIDCReducer.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
RESET,
1212
SEARCH_CLIENTS,
1313
SET_VIEW,
14+
GET_UMA_RESOURCES
1415
} from '../actions/types'
1516
import reducerRegistry from 'Redux/reducers/ReducerRegistry'
1617

@@ -21,6 +22,7 @@ const INIT_STATE = {
2122
loading: false,
2223
saveOperationFlag: false,
2324
errorInSaveOperationFlag: false,
25+
umaResources: {},
2426
}
2527

2628
const reducerName = 'oidcReducer'
@@ -127,7 +129,11 @@ export default function oidcReducer(state = INIT_STATE, action) {
127129
} else {
128130
return handleDefault()
129131
}
130-
132+
case GET_UMA_RESOURCES:
133+
return {
134+
...state,
135+
umaResources: action.payload.item,
136+
}
131137
case RESET:
132138
return {
133139
...state,

admin-ui/plugins/auth-server/redux/sagas/OIDCSaga.js

+22
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
EDIT_CLIENT,
2525
DELETE_CLIENT,
2626
SEARCH_CLIENTS,
27+
GET_UMA_RESOURCES
2728
} from '../actions/types'
2829
import OIDCApi from '../api/OIDCApi'
2930
import { getClient } from 'Redux/api/base'
@@ -122,6 +123,23 @@ export function* deleteAClient({ payload }) {
122123
}
123124
}
124125

126+
export function* getUMAResourcesByClient(inum) {
127+
const audit = yield* initAudit()
128+
try {
129+
addAdditionalData(audit, FETCH, GET_UMA_RESOURCES, {})
130+
const api = yield* newFunction()
131+
const data = yield call(api.getOauthUmaResourcesByClientid, inum)
132+
yield put(deleteClientResponse(data))
133+
yield call(postUserAction, audit)
134+
} catch (e) {
135+
yield put(deleteClientResponse(null))
136+
if (isFourZeroOneError(e)) {
137+
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
138+
yield put(getAPIAccessToken(jwt))
139+
}
140+
}
141+
}
142+
125143
export function* getOpenidClientsWatcher() {
126144
yield takeLatest(GET_OPENID_CLIENTS, getOauthOpenidClients)
127145
}
@@ -140,6 +158,9 @@ export function* editClientWatcher() {
140158
export function* deleteClientWatcher() {
141159
yield takeLatest(DELETE_CLIENT, deleteAClient)
142160
}
161+
export function* getUMAResourcesByClientWatcher() {
162+
yield takeLatest(GET_UMA_RESOURCES, getUMAResourcesByClient)
163+
}
143164

144165
export default function* rootSaga() {
145166
yield all([
@@ -148,5 +169,6 @@ export default function* rootSaga() {
148169
fork(addClientWatcher),
149170
fork(editClientWatcher),
150171
fork(deleteClientWatcher),
172+
fork(getUMAResourcesByClientWatcher),
151173
])
152174
}

0 commit comments

Comments
 (0)