Skip to content

Commit 1132401

Browse files
committed
Find tokens by regex
1 parent e7d0192 commit 1132401

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

aws_role.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package saml2aws
22

33
import (
44
"fmt"
5+
"regexp"
56
"strings"
67
)
78

@@ -29,7 +30,8 @@ func ParseAWSRoles(roles []string) ([]*AWSRole, error) {
2930
}
3031

3132
func parseRole(role string) (*AWSRole, error) {
32-
tokens := strings.Split(role, ",")
33+
r, _ := regexp.Compile("arn:([^:\n]*):([^:\n]*):([^:\n]*):([^:\n]*):(([^:/\n]*)[:/])?([^:,\n]*)")
34+
tokens := r.FindAllString(role, -1)
3335

3436
if len(tokens) != 2 {
3537
return nil, fmt.Errorf("Invalid role string only %d tokens", len(tokens))

0 commit comments

Comments
 (0)