diff --git a/.golangci.yml b/.golangci.yml index d5d49ce9..03626a58 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,10 +13,6 @@ linters: linters-settings: misspell: locale: US - golint: - min-confidence: 0 - govet: - check-shadowing: false goimports: local-prefixes: github.com/Nerzal/gocloak gocognit: diff --git a/client.go b/client.go index 63d39700..c06063be 100644 --- a/client.go +++ b/client.go @@ -66,7 +66,7 @@ func makeURL(path ...string) string { func (g *GoCloak) compareVersions(v, token string, ctx context.Context) (int, error) { curVersion := g.Config.version if curVersion == "" { - curV, err := g.getServerVersion(ctx, token); + curV, err := g.getServerVersion(ctx, token) if err != nil { return 0, err } @@ -75,7 +75,7 @@ func (g *GoCloak) compareVersions(v, token string, ctx context.Context) (int, er } curVersion = "v" + g.Config.version - if (v[0] != 'v') { + if v[0] != 'v' { v = "v" + v } @@ -777,7 +777,7 @@ func (g *GoCloak) ExecuteActionsEmail(ctx context.Context, token, realm string, // SendVerifyEmail sends a verification e-mail to a user. func (g *GoCloak) SendVerifyEmail(ctx context.Context, token, userID, realm string, params ...SendVerificationMailParams) error { - const errMessage = "could not execute actions email" + const errMessage = "failed to send verify email" queryParams := map[string]string{} if params != nil { diff --git a/client_test.go b/client_test.go index 205e95ea..9a39059a 100644 --- a/client_test.go +++ b/client_test.go @@ -2639,7 +2639,7 @@ func Test_SendVerifyEmail(t *testing.T) { cfg.GoCloak.Realm, params) if err != nil { - if err.Error() == "500 Internal Server Error: Failed to send verify email" { + if err.Error() == "500 Internal Server Error: Failed to send execute actions email" { return } require.NoError(t, err, "SendVerifyEmail failed") @@ -6641,14 +6641,13 @@ func Test_ImportIdentityProviderConfig(t *testing.T) { require.NoError(t, err, "ImportIdentityProviderConfig failed") expected := map[string]string{ - "userInfoUrl": "https://openidconnect.googleapis.com/v1/userinfo", - "validateSignature": "true", - "tokenUrl": "https://oauth2.googleapis.com/token", - "authorizationUrl": "https://accounts.google.com/o/oauth2/v2/auth", - "jwksUrl": "https://www.googleapis.com/oauth2/v3/certs", - "issuer": "https://accounts.google.com", - "useJwksUrl": "true", - "metadataDescriptorUrl": "https://accounts.google.com/.well-known/openid-configuration", + "userInfoUrl": "https://openidconnect.googleapis.com/v1/userinfo", + "validateSignature": "true", + "tokenUrl": "https://oauth2.googleapis.com/token", + "authorizationUrl": "https://accounts.google.com/o/oauth2/v2/auth", + "jwksUrl": "https://www.googleapis.com/oauth2/v3/certs", + "issuer": "https://accounts.google.com", + "useJwksUrl": "true", } require.Len( @@ -6723,7 +6722,6 @@ E8go1LcvbfHNyknHu2sptnRq55fHZSHr18vVsQRfDYMG "loginHint": "false", "enabledFromMetadata": "true", "idpEntityId": "https://accounts.google.com/o/saml2?idpid=C01unc9st", - "syncMode": "LEGACY", } require.Len( diff --git a/gocloak_iface.go b/gocloak_iface.go index be49353c..32dbf9b3 100644 --- a/gocloak_iface.go +++ b/gocloak_iface.go @@ -61,6 +61,9 @@ type GoCloakIface interface { // LoginClientTokenExchange will exchange the presented token for a user's token // Requires Token-Exchange is enabled: https://www.keycloak.org/docs/latest/securing_apps/index.html#_token-exchange LoginClientTokenExchange(ctx context.Context, clientID, token, clientSecret, realm, targetClient, userID string) (*JWT, error) + // DirectNakedImpersonationTokenExchange performs "Direct Naked Impersonation" + // See: https://www.keycloak.org/docs/latest/securing_apps/index.html#direct-naked-impersonation + DirectNakedImpersonationTokenExchange(ctx context.Context, clientID, clientSecret, realm, userID string) (*JWT, error) // LoginClientSignedJWT performs a login with client credentials and signed jwt claims LoginClientSignedJWT(ctx context.Context, clientID, realm string, key interface{}, signedMethod jwt.SigningMethod, expiresAt *jwt.NumericDate) (*JWT, error) // Login performs a login with user credentials and a client @@ -159,6 +162,8 @@ type GoCloakIface interface { GetClientScopeProtocolMapper(ctx context.Context, token, realm, scopeID, protocolMapperID string) (*ProtocolMappers, error) // GetClientScopeMappings returns all scope mappings for the client GetClientScopeMappings(ctx context.Context, token, realm, idOfClient string) (*MappingsRepresentation, error) + // GetRealmRoleGroups returns groups associated with the realm role + GetRealmRoleGroups(ctx context.Context, token, roleName, realm string) ([]*Group, error) // GetClientScopeMappingsRealmRoles returns realm-level roles associated with the client’s scope GetClientScopeMappingsRealmRoles(ctx context.Context, token, realm, idOfClient string) ([]*Role, error) // GetClientScopeMappingsRealmRolesAvailable returns realm-level roles that are available to attach to this client’s scope @@ -213,6 +218,8 @@ type GoCloakIface interface { GetRoleMappingByUserID(ctx context.Context, token, realm, userID string) (*MappingsRepresentation, error) // GetGroup get group with id in realm GetGroup(ctx context.Context, token, realm, groupID string) (*Group, error) + // GetChildGroups get child groups of group with id in realm + GetChildGroups(ctx context.Context, token, realm, groupID string, params GetChildGroupsParams) ([]*Group, error) // GetGroupByPath get group with path in realm GetGroupByPath(ctx context.Context, token, realm, groupPath string) (*Group, error) // GetGroups get all groups in realm @@ -493,6 +500,8 @@ type GoCloakIface interface { GetDependentPermissions(ctx context.Context, token, realm, idOfClient, policyID string) ([]*PermissionRepresentation, error) // GetPermissionResources returns a client's resource attached for the given permission id GetPermissionResources(ctx context.Context, token, realm, idOfClient, permissionID string) ([]*PermissionResource, error) + // GetScopePermissions returns permissions associated with the client scope + GetScopePermissions(ctx context.Context, token, realm, idOfClient, idOfScope string) ([]*PolicyRepresentation, error) // GetPermissionScopes returns a client's scopes configured for the given permission id GetPermissionScopes(ctx context.Context, token, realm, idOfClient, permissionID string) ([]*PermissionScope, error) // GetPermissions returns permissions associated with the client @@ -541,6 +550,8 @@ type GoCloakIface interface { CreateClientScopesScopeMappingsRealmRoles(ctx context.Context, token, realm, clientScopeID string, roles []Role) error // RegisterRequiredAction creates a required action for a given realm RegisterRequiredAction(ctx context.Context, token string, realm string, requiredAction RequiredActionProviderRepresentation) error + // GetUnregisteredRequiredActions gets a list of unregistered required actions for a given realm + GetUnregisteredRequiredActions(ctx context.Context, token string, realm string) ([]*UnregisteredRequiredActionProviderRepresentation, error) // GetRequiredActions gets a list of required actions for a given realm GetRequiredActions(ctx context.Context, token string, realm string) ([]*RequiredActionProviderRepresentation, error) // GetRequiredAction gets a required action for a given realm