Merge branch 'chore/rename-schema-roles-colon-convention' into 'main'
chore(auth): rename schema workflow roles к colon-convention See merge request 2-6/2-6-4/terravault/ordinis!161
This commit is contained in:
@@ -11,31 +11,46 @@ import { useAuth } from 'react-oidc-context'
|
||||
* </ul>
|
||||
*
|
||||
* <p>Phase 1d: подключим decode JWT → realm_access.roles, и эти hook'и
|
||||
* начнут возвращать false для users без \`ordinis-schema-reviewer\` /
|
||||
* \`ordinis-schema-publisher\` ролей. UI hide'ит соответствующие кнопки.
|
||||
* начнут возвращать false для users без {@code ordinis:schema:reviewer}
|
||||
* / {@code ordinis:schema:publisher} ролей. UI hide'ит соответствующие
|
||||
* кнопки.
|
||||
*
|
||||
* <p><b>Naming convention:</b> roles используют colon-separated namespace
|
||||
* pattern {@code ordinis:<domain>:<action>} (как Altum-style scope roles
|
||||
* вида {@code ordinis:client:restricted}). Совпадает с realm role parser
|
||||
* в {@code ScopeContext.java}. Dash-форма ({@code ordinis-schema-reviewer})
|
||||
* НЕ используется в этом проекте — colon-стиль consistent с уже-existing
|
||||
* scope ролями ({@code ordinis:client:public|internal|restricted}).
|
||||
*
|
||||
* <p>До тех пор все logged-in юзеры могут жать любые workflow buttons —
|
||||
* backend гейт остаётся primary defence.
|
||||
*/
|
||||
|
||||
const ROLE_SCHEMA_REVIEWER = 'ordinis:schema:reviewer'
|
||||
const ROLE_SCHEMA_PUBLISHER = 'ordinis:schema:publisher'
|
||||
const ROLE_SCHEMA_MAKER = 'ordinis:schema:maker'
|
||||
|
||||
/** Может ли актор approve / request_changes / reject schema draft. */
|
||||
export function useCanReviewSchema(): boolean {
|
||||
const auth = useAuth()
|
||||
// TODO Phase 1d: const roles = (auth.user?.profile as { realm_access?: { roles?: string[] } })?.realm_access?.roles ?? []
|
||||
// return roles.includes('ordinis-schema-reviewer')
|
||||
// return roles.includes(ROLE_SCHEMA_REVIEWER)
|
||||
void ROLE_SCHEMA_REVIEWER
|
||||
return auth.isAuthenticated
|
||||
}
|
||||
|
||||
/** Может ли актор publish approved schema draft (bump live version). */
|
||||
export function useCanPublishSchema(): boolean {
|
||||
const auth = useAuth()
|
||||
// TODO Phase 1d: roles.includes('ordinis-schema-publisher')
|
||||
// TODO Phase 1d: roles.includes(ROLE_SCHEMA_PUBLISHER)
|
||||
void ROLE_SCHEMA_PUBLISHER
|
||||
return auth.isAuthenticated
|
||||
}
|
||||
|
||||
/** Может ли актор create schema draft (maker side). */
|
||||
export function useCanCreateSchemaDraft(): boolean {
|
||||
const auth = useAuth()
|
||||
// TODO Phase 1d: roles.includes('ordinis-schema-maker') OR any authenticated
|
||||
// TODO Phase 1d: roles.includes(ROLE_SCHEMA_MAKER) OR any authenticated
|
||||
void ROLE_SCHEMA_MAKER
|
||||
return auth.isAuthenticated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user