Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(User Roles) Remove legacy scopes #7792

Open
wants to merge 19 commits into
base: configurable-roles
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Breaking changes

- Removed unused searchBirthRegistrations and searchDeathRegistrations queries, as they are no longer used by the client.

- **Title** Description

## Improvements
Expand Down
7 changes: 6 additions & 1 deletion packages/auth/src/features/authenticateSuperUser/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@auth/features/authenticate/service'
import { unauthorized } from '@hapi/boom'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from '@auth/constants'
import { SUPER_ADMIN_SCOPES } from '@opencrvs/commons/authentication'
import { Scope, SCOPES } from '@opencrvs/commons/authentication'
import { logger } from '@opencrvs/commons'

interface IAuthPayload {
Expand All @@ -43,6 +43,11 @@ export default async function authenticateSuperUserHandler(
throw unauthorized()
}

const SUPER_ADMIN_SCOPES = [
SCOPES.BYPASSRATELIMIT,
SCOPES.CONFIG_UPDATE_ALL
] satisfies Scope[]

const token = await createToken(
result.userId,
SUPER_ADMIN_SCOPES,
Expand Down
92 changes: 3 additions & 89 deletions packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7281,13 +7281,9 @@
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "UserRole",
"ofType": null
}
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
Expand Down Expand Up @@ -14044,88 +14040,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "searchBirthRegistrations",
"description": null,
"args": [
{
"name": "fromDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "toDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "BirthRegistration",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "searchDeathRegistrations",
"description": null,
"args": [
{
"name": "fromDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "toDate",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Date",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "DeathRegistration",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "searchEvents",
"description": null,
Expand Down
8 changes: 1 addition & 7 deletions packages/client/src/profile/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ const FETCH_USER = gql`
firstNames
familyName
}
role {
label {
id
defaultMessage
description
}
}
role
signature {
data
type
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/tests/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,6 @@ type Query {
to: Date
): [Notification]
fetchBirthRegistration(id: ID!): BirthRegistration
searchBirthRegistrations(fromDate: Date, toDate: Date): [BirthRegistration]
searchDeathRegistrations(fromDate: Date, toDate: Date): [DeathRegistration]
queryRegistrationByIdentifier(identifier: ID!): BirthRegistration
queryPersonByIdentifier(identifier: ID!): Person
listBirthRegistrations(
Expand Down
10 changes: 0 additions & 10 deletions packages/client/src/tests/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ export const ACTION_STATUS_MAP = {
SUBMISSION_STATUS.READY_TO_REQUEST_CORRECTION
} as const

export const validateScopeToken = jwt.sign(
{ scope: ['validate'] },
readFileSync('./test/cert.key'),
{
algorithm: 'RS256',
issuer: 'opencrvs:auth-service',
audience: 'opencrvs:gateway-user'
}
)

export function flushPromises() {
return new Promise((resolve) => setImmediate(resolve))
}
Expand Down
4 changes: 0 additions & 4 deletions packages/client/src/utils/gateway-deprecated-do-not-use.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { GraphQLResolveInfo, GraphQLScalarType } from 'graphql'
export interface GQLQuery {
listNotifications?: Array<GQLNotification | null>
fetchBirthRegistration?: GQLBirthRegistration
searchBirthRegistrations?: Array<GQLBirthRegistration | null>
searchDeathRegistrations?: Array<GQLDeathRegistration | null>
queryRegistrationByIdentifier?: GQLBirthRegistration
queryPersonByIdentifier?: GQLPerson
listBirthRegistrations?: GQLBirthRegResultSet
Expand Down Expand Up @@ -2032,8 +2030,6 @@ export interface GQLResolver {
export interface GQLQueryTypeResolver<TParent = any> {
listNotifications?: QueryToListNotificationsResolver<TParent>
fetchBirthRegistration?: QueryToFetchBirthRegistrationResolver<TParent>
searchBirthRegistrations?: QueryToSearchBirthRegistrationsResolver<TParent>
searchDeathRegistrations?: QueryToSearchDeathRegistrationsResolver<TParent>
queryRegistrationByIdentifier?: QueryToQueryRegistrationByIdentifierResolver<TParent>
queryPersonByIdentifier?: QueryToQueryPersonByIdentifierResolver<TParent>
listBirthRegistrations?: QueryToListBirthRegistrationsResolver<TParent>
Expand Down
16 changes: 4 additions & 12 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const scopes = [
'record.registration-revoke',
'record.registration-request-reinstatement',
'record.registration-reinstate',
'record.certify',
'search.birth:my-jurisdiction',
'search.birth',
'search.death:my-jurisdiction',
Expand Down Expand Up @@ -145,6 +146,7 @@ export const SCOPES = {
RECORD_REGISTRATION_REQUEST_REINSTATEMENT:
'record.registration-request-reinstatement',
RECORD_REGISTRATION_REINSTATE: 'record.registration-reinstate',
RECORD_CERTIFY: 'record.certify',
SEARCH_BIRTH_MY_JURISDICTION: 'search.birth:my-jurisdiction',
SEARCH_BIRTH: 'search.birth',
SEARCH_DEATH_MY_JURISDICTION: 'search.death:my-jurisdiction',
Expand Down Expand Up @@ -945,7 +947,7 @@ export enum IntegratingSystemType {
export type LocalRegistrar = {
__typename?: 'LocalRegistrar'
name: Array<Maybe<HumanName>>
role: UserRole
role?: Maybe<Scalars['String']>
signature?: Maybe<Signature>
}

Expand Down Expand Up @@ -1569,8 +1571,6 @@ export type Query = {
queryPersonByIdentifier?: Maybe<Person>
queryPersonByNidIdentifier?: Maybe<Person>
queryRegistrationByIdentifier?: Maybe<BirthRegistration>
searchBirthRegistrations?: Maybe<Array<Maybe<BirthRegistration>>>
searchDeathRegistrations?: Maybe<Array<Maybe<DeathRegistration>>>
searchEvents?: Maybe<EventSearchResultSet>
searchFieldAgents?: Maybe<SearchFieldAgentResult>
searchUsers?: Maybe<SearchUserResult>
Expand Down Expand Up @@ -2716,21 +2716,13 @@ export type FetchUserQuery = {
}
localRegistrar?: {
__typename?: 'LocalRegistrar'
role?: string | null
name: Array<{
__typename?: 'HumanName'
use?: string | null
firstNames?: string | null
familyName?: string | null
} | null>
role: {
__typename?: 'UserRole'
label: {
__typename?: 'I18nMessage'
id: string
defaultMessage: string
description: string
}
}
signature?: {
__typename?: 'Signature'
data?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const EVENT_CREATION_TIME = 1583322631424 // Wed Mar 04 2020 13:50:31 GMT+0200 (
const SEND_FOR_VALIDATION_TIME = 1582912800000 // Fri Feb 28 2020 20:00:00 GMT+0200 (Eastern European Standard Time)

const registerScopeToken = jwt.sign(
{ scope: ['register'] },
{ scope: ['record.register'] },
readFileSync('./test/cert.key'),
{
algorithm: 'RS256',
Expand Down
6 changes: 0 additions & 6 deletions packages/commons/src/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export const SYSTEM_INTEGRATION_SCOPES = {
nationalId: SCOPES.NATIONALID
} as const

export const SUPER_ADMIN_SCOPES = [
SCOPES.NATLSYSADMIN,
SCOPES.BYPASSRATELIMIT,
SCOPES.SYSADMIN
] satisfies Scope[]

export const DEFAULT_ROLES_DEFINITION = [
{
id: 'FIELD_AGENT',
Expand Down
1 change: 1 addition & 0 deletions packages/commons/src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const SCOPES = {
RECORD_REGISTRATION_REQUEST_REINSTATEMENT:
'record.registration-request-reinstatement',
RECORD_REGISTRATION_REINSTATE: 'record.registration-reinstate',
RECORD_CERTIFY: 'record.certify',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nil20 Do we have a scope like that in notion? To me the equivalent for our previous 'certify' scope would be record.declaration-print


// search
SEARCH_BIRTH_MY_JURISDICTION: 'search.birth:my-jurisdiction',
Expand Down
Loading
Loading