Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit e1ea805

Browse files
committed
update 2fa m2m scopes
1 parent 9be0e04 commit e1ea805

File tree

7 files changed

+60
-98
lines changed

7 files changed

+60
-98
lines changed

buildtokenproperties.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ M2MAUTHCONFIG_USERPROFILES_CREATE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USERPROFIL
4343
M2MAUTHCONFIG_USERPROFILES_UPDATE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USERPROFILES_UPDATE")
4444
M2MAUTHCONFIG_USERPROFILES_READ=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USERPROFILES_READ")
4545
M2MAUTHCONFIG_USERPROFILES_DELETE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USERPROFILES_DELETE")
46-
M2MAUTHCONFIG_USER2FA_CREATE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_CREATE")
47-
M2MAUTHCONFIG_USER2FA_UPDATE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_UPDATE")
48-
M2MAUTHCONFIG_USER2FA_READ=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_READ")
49-
M2MAUTHCONFIG_USER2FA_DELETE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_DELETE")
46+
M2MAUTHCONFIG_USER2FA_ENABLE=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_ENABLE")
47+
M2MAUTHCONFIG_USER2FA_VERIFY=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_VERIFY")
48+
M2MAUTHCONFIG_USER2FA_CREDENTIAL=$(eval "echo \$${ENV}_M2MAUTHCONFIG_USER2FA_CREDENTIAL")
5049

5150
DOMAIN=$(eval "echo \$${ENV}_DOMAIN")
5251
SMTP=$(eval "echo \$${ENV}_SMTP")
@@ -135,10 +134,9 @@ perl -pi -e "s|\{\{M2MAUTHCONFIG_USERPROFILES_CREATE\}\}|$M2MAUTHCONFIG_USERPROF
135134
perl -pi -e "s|\{\{M2MAUTHCONFIG_USERPROFILES_UPDATE\}\}|$M2MAUTHCONFIG_USERPROFILES_UPDATE|g" $CONFFILENAME
136135
perl -pi -e "s|\{\{M2MAUTHCONFIG_USERPROFILES_READ\}\}|$M2MAUTHCONFIG_USERPROFILES_READ|g" $CONFFILENAME
137136
perl -pi -e "s|\{\{M2MAUTHCONFIG_USERPROFILES_DELETE\}\}|$M2MAUTHCONFIG_USERPROFILES_DELETE|g" $CONFFILENAME
138-
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_CREATE\}\}|$M2MAUTHCONFIG_USER2FA_CREATE|g" $CONFFILENAME
139-
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_UPDATE\}\}|$M2MAUTHCONFIG_USER2FA_UPDATE|g" $CONFFILENAME
140-
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_READ\}\}|$M2MAUTHCONFIG_USER2FA_READ|g" $CONFFILENAME
141-
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_DELETE\}\}|$M2MAUTHCONFIG_USER2FA_DELETE|g" $CONFFILENAME
137+
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_ENABLE\}\}|$M2MAUTHCONFIG_USER2FA_ENABLE|g" $CONFFILENAME
138+
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_VERIFY\}\}|$M2MAUTHCONFIG_USER2FA_VERIFY|g" $CONFFILENAME
139+
perl -pi -e "s|\{\{M2MAUTHCONFIG_USER2FA_CREDENTIAL\}\}|$M2MAUTHCONFIG_USER2FA_CREDENTIAL|g" $CONFFILENAME
142140
perl -pi -e "s/\{\{AUTH0_NEW_DOMAIN\}\}/$AUTH0_NEW_DOMAIN/g" $CONFFILENAME
143141
perl -pi -e "s/\{\{AUTH0_DOMAIN\}\}/$AUTH0_DOMAIN/g" $CONFFILENAME
144142
perl -pi -e "s/\{\{SENDGRID_RESEND_ACTIVATION_EMAIL_TEMPLATE_ID\}\}/$SENDGRID_RESEND_ACTIVATION_EMAIL_TEMPLATE_ID/g" $CONFFILENAME

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,7 @@ public ApiResponse updateUser2fa(
15181518
@Context HttpServletRequest request) {
15191519

15201520
TCID id = new TCID(resourceId);
1521-
validateResourceIdAndCheckPermission(authUser, id, user2faFactory.getUpdateScopes());
1521+
validateResourceIdAndCheckPermission(authUser, id, user2faFactory.getEnableScopes());
15221522
// checking param
15231523
checkParam(postRequest);
15241524

@@ -1576,7 +1576,7 @@ public ApiResponse issueCredentials(
15761576
@Auth AuthUser authUser,
15771577
@Valid PostPutRequest<CredentialRequest> postRequest,
15781578
@Context HttpServletRequest request) {
1579-
Utils.checkAccess(authUser, user2faFactory.getCreateScopes(), Utils.AdminRoles);
1579+
Utils.checkAccess(authUser, user2faFactory.getCredentialIssuerScopes(), Utils.AdminRoles);
15801580
checkParam(postRequest);
15811581
CredentialRequest credential = postRequest.getParam();
15821582

@@ -1654,7 +1654,7 @@ public ApiResponse update2faVerification(
16541654
@Valid PostPutRequest<User2fa> putRequest,
16551655
@Context HttpServletRequest request) {
16561656

1657-
Utils.checkAccess(authUser, user2faFactory.getUpdateScopes(), Utils.AdminRoles);
1657+
Utils.checkAccess(authUser, user2faFactory.getVerifyScopes(), Utils.AdminRoles);
16581658
checkParam(putRequest);
16591659
User2fa credential = putRequest.getParam();
16601660

src/main/java/com/appirio/tech/core/service/identity/util/m2mscope/User2faFactory.java

Lines changed: 39 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,131 +12,99 @@ public class User2faFactory {
1212
/**
1313
* Represents the create scopes for machine token validation.
1414
*/
15-
public static final String[] ReadScopes = { "all:user_2fa" };
15+
public static final String[] EnableScopes = { "enable:user_2fa", "all:user_2fa" };
1616

1717
/**
1818
* Represents the create scopes for machine token validation.
1919
*/
20-
public static final String[] CreateScopes = { "all:user_2fa" };
21-
22-
/**
23-
* Represents the delete scopes for machine token validation.
24-
*/
25-
public static final String[] DeleteScopes = { "all:user_2fa" };
20+
public static final String[] VerifyScopes = { "verify:user_2fa", "all:user_2fa" };
2621

2722
/**
2823
* Represents the update scopes for machine token validation.
2924
*/
30-
public static final String[] UpdateScopes = { "all:user_2fa" };
25+
public static final String[] CredentialIssuerScopes = { "cred:user_2fa", "all:user_2fa" };
3126

3227
/**
33-
* Represents the read attribute
28+
* Represents the enable attribute
3429
*/
3530
@JsonProperty
36-
private String read;
31+
private String enable;
3732

3833
/**
39-
* Represents the create attribute
34+
* Represents the verify attribute
4035
*/
4136
@JsonProperty
42-
private String create;
37+
private String verify;
4338

4439
/**
45-
* Represents the update attribute
40+
* Represents the credential attribute
4641
*/
4742
@JsonProperty
48-
private String update;
49-
50-
/**
51-
* Represents the delete attribute
52-
*/
53-
@JsonProperty
54-
private String delete;
43+
private String credential;
5544

5645
public User2faFactory() {
5746
}
5847

59-
public String getRead() {
60-
return read;
61-
}
62-
63-
public void setRead(String read) {
64-
this.read = read;
48+
public String getEnable() {
49+
return enable;
6550
}
6651

67-
public String getCreate() {
68-
return create;
52+
public void setEnable(String enable) {
53+
this.enable = enable;
6954
}
7055

71-
public void setCreate(String create) {
72-
this.create = create;
56+
public String getVerify() {
57+
return verify;
7358
}
7459

75-
public String getUpdate() {
76-
return update;
60+
public void SetVerify(String verify) {
61+
this.verify = verify;
7762
}
7863

79-
public void setUpdate(String update) {
80-
this.update = update;
64+
public String getCredential() {
65+
return credential;
8166
}
8267

83-
public String getDelete() {
84-
return delete;
85-
}
86-
87-
public void setDelete(String delete) {
88-
this.delete = delete;
89-
}
90-
91-
/**
92-
* Gets the read scopes.
93-
*
94-
* @return the read scopes.
95-
*/
96-
public String[] getReadScopes() {
97-
if (read != null && read.trim().length() != 0) {
98-
return read.split(SCOPE_DELIMITER);
99-
}
100-
101-
return ReadScopes;
68+
public void setCredential(String credential) {
69+
this.credential = credential;
10270
}
10371

10472
/**
105-
* Gets the create scopes.
73+
* Gets the enable scopes.
10674
*
107-
* @return the create scopes.
75+
* @return the enable scopes.
10876
*/
109-
public String[] getCreateScopes() {
110-
if (create != null && create.trim().length() != 0) {
111-
return create.split(SCOPE_DELIMITER);
77+
public String[] getEnableScopes() {
78+
if (enable != null && enable.trim().length() != 0) {
79+
return enable.split(SCOPE_DELIMITER);
11280
}
11381

114-
return CreateScopes;
82+
return EnableScopes;
11583
}
11684

11785
/**
118-
* Gets the update scopes.
86+
* Gets the verify scopes.
11987
*
120-
* @return the update scopes.
88+
* @return the verify scopes.
12189
*/
122-
public String[] getUpdateScopes() {
123-
if (update != null && update.trim().length() != 0) {
124-
return update.split(SCOPE_DELIMITER);
90+
public String[] getVerifyScopes() {
91+
if (verify != null && verify.trim().length() != 0) {
92+
return verify.split(SCOPE_DELIMITER);
12593
}
12694

127-
return UpdateScopes;
95+
return VerifyScopes;
12896
}
12997

13098
/**
131-
* Gets the delete scopes.
99+
* Gets the credential issuer scopes.
132100
*
133-
* @return the delete scopes.
101+
* @return the credential issuer scopes.
134102
*/
135-
public String[] getDeleteScopes() {
136-
if (delete != null && delete.trim().length() != 0) {
137-
return delete.split(SCOPE_DELIMITER);
103+
public String[] getCredentialIssuerScopes() {
104+
if (credential != null && credential.trim().length() != 0) {
105+
return credential.split(SCOPE_DELIMITER);
138106
}
139107

140-
return DeleteScopes;
108+
return CredentialIssuerScopes;
141109
}
142110
}

src/main/resources/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ m2mAuthConfig:
170170
update: @m2mAuthConfig.userProfiles.update@
171171
delete: @m2mAuthConfig.userProfiles.delete@
172172
user2fa:
173-
create: @m2mAuthConfig.user2fa.create@
174-
read: @m2mAuthConfig.user2fa.read@
175-
update: @m2mAuthConfig.user2fa.update@
176-
delete: @m2mAuthConfig.user2fa.delete@
173+
enable: @m2mAuthConfig.user2fa.enable@
174+
verify: @m2mAuthConfig.user2fa.verify@
175+
credential: @m2mAuthConfig.user2fa.credential@
177176

178177
# Server settings
179178
server:

src/main/resources/config.yml.localdev

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ m2mAuthConfig:
169169
update: update:user_profiles,all:user_profiles
170170
delete: delete:user_profiles,all:user_profiles
171171
user2fa:
172-
create: all:user-2fa
173-
read: all:user-2fa
174-
update: all:user-2fa
175-
delete: all:user-2fa
172+
enable: enable:user-2fa,all:user-2fa
173+
verify: verify:user-2fa,all:user-2fa
174+
credential: cred:user-2fa,all:user-2fa
176175

177176
# Server settings
178177
server:

token.properties.localdev

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
@m2mAuthConfig.userProfiles.read@=read:user_profiles,all:user_profiles
7878
@m2mAuthConfig.userProfiles.update@=update:user_profiles,all:user_profiles
7979
@m2mAuthConfig.userProfiles.delete@=delete:user_profiles,all:user_profiles
80-
@m2mAuthConfig.user2fa.create@=create:user_2fa,all:user_2fa
81-
@m2mAuthConfig.user2fa.read@=read:user_2fa,all:user_2fa
82-
@m2mAuthConfig.user2fa.update@=update:user_2fa,all:user_2fa
83-
@m2mAuthConfig.user2fa.delete@=delete:user_2fa,all:user_2fa
80+
@m2mAuthConfig.user2fa.enable@=enable:user_2fa,all:user_2fa
81+
@m2mAuthConfig.user2fa.verify@=verify:user_2fa,all:user_2fa
82+
@m2mAuthConfig.user2fa.credential@=cred:user_2fa,all:user_2fa

token.properties.template

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
@m2mAuthConfig.userProfiles.read@={{M2MAUTHCONFIG_USERPROFILES_READ}}
100100
@m2mAuthConfig.userProfiles.update@={{M2MAUTHCONFIG_USERPROFILES_UPDATE}}
101101
@m2mAuthConfig.userProfiles.delete@={{M2MAUTHCONFIG_USERPROFILES_DELETE}}
102-
@m2mAuthConfig.user2fa.create@={{M2MAUTHCONFIG_USER2FA_CREATE}}
103-
@m2mAuthConfig.user2fa.read@={{M2MAUTHCONFIG_USER2FA_READ}}
104-
@m2mAuthConfig.user2fa.update@={{M2MAUTHCONFIG_USER2FA_UPDATE}}
105-
@m2mAuthConfig.user2fa.delete@={{M2MAUTHCONFIG_USER2FA_DELETE}}
102+
@m2mAuthConfig.user2fa.enable@={{M2MAUTHCONFIG_USER2FA_ENABLE}}
103+
@m2mAuthConfig.user2fa.verify@={{M2MAUTHCONFIG_USER2FA_VERIFY}}
104+
@m2mAuthConfig.user2fa.credential@={{M2MAUTHCONFIG_USER2FA_CREDENTIAL}}

0 commit comments

Comments
 (0)