Documentation
¶
Overview ¶
Package scope provides functions for validating OIDC scopes.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Valid ¶
Valid takes a string representing token scope and validates if the token conforms to RFC6749. If the token does not contain invalid characters it returns true, false otherwise.
Ref. https://datatracker.ietf.org/doc/html/rfc6749#section-3.3
Example (InvalidTokens) ¶
package main import ( "fmt" "github.com/qba73/scope" ) func main() { fmt.Println(scope.Valid("my\x18scope+second\x7fScope")) }
Output: false
Example (ValidTokens) ¶
package main import ( "fmt" "github.com/qba73/scope" ) func main() { fmt.Println(scope.Valid("myscope")) }
Output: true
func ValidOIDC ¶ added in v0.1.1
ValidOIDC takes a string representing OIDC scope and validates if all tokens in the scope conforms to RFC6749. The input string (scope) is expected to have the following formats:
`openid+scope1+scope2` `scope1+openid+scope2`
Tokens should be separated by `+` sign. Order of tokens does not matter. ValidOIDC checks if the mandatory token `openid` is present in the scope. If it is not present the func returns false. If any token in the scope contains invalid characters the func will return false.
Ref.
- https://openid.net/specs/openid-connect-core-1_0.html section 3.1.2.1 (Authentication Request)
- https://datatracker.ietf.org/doc/html/rfc6749#section-3.3
Example (InvalidTokens) ¶
package main import ( "fmt" "github.com/qba73/scope" ) func main() { fmt.Println(scope.ValidOIDC("openid m\x7fyscope")) }
Output: false
Example (MissingRequiredToken) ¶
package main import ( "fmt" "github.com/qba73/scope" ) func main() { fmt.Println(scope.ValidOIDC("secondScope email")) }
Output: false
Example (ValidTokens) ¶
package main import ( "fmt" "github.com/qba73/scope" ) func main() { fmt.Println(scope.ValidOIDC("openid myscope")) }
Output: true
Types ¶
This section is empty.