MCPcopy Create free account
hub / github.com/AfterShip/clickhouse-sql-parser / parseAuthenticationClause

Method parseAuthenticationClause

parser/parse_system.go:539–599  ·  view source on GitHub ↗
(pos Pos)

Source from the content-addressed store, hash-verified

537}
538
539func (p *Parser) parseAuthenticationClause(pos Pos) (*AuthenticationClause, error) {
540 auth := &AuthenticationClause{AuthPos: pos}
541
542 if p.tryConsumeKeywords(KeywordNot) {
543 if err := p.expectKeyword(KeywordIdentified); err != nil {
544 return nil, err
545 }
546 auth.NotIdentified = true
547 auth.AuthEnd = p.last().End
548 return auth, nil
549 }
550
551 if err := p.expectKeyword(KeywordIdentified); err != nil {
552 return nil, err
553 }
554 auth.AuthEnd = p.last().End
555
556 if p.tryConsumeKeywords(KeywordWith) {
557 if p.matchKeyword(KeywordLdap) {
558 _ = p.lexer.consumeToken()
559 if err := p.expectKeyword(KeywordServer); err != nil {
560 return nil, err
561 }
562 server, err := p.parseString(p.Pos())
563 if err != nil {
564 return nil, err
565 }
566 auth.LdapServer = server
567 auth.AuthEnd = server.End()
568 } else if p.matchKeyword(KeywordKerberos) {
569 _ = p.lexer.consumeToken()
570 auth.IsKerberos = true
571 auth.AuthEnd = p.last().End
572 if p.tryConsumeKeywords(KeywordRealm) {
573 realm, err := p.parseString(p.Pos())
574 if err != nil {
575 return nil, err
576 }
577 auth.KerberosRealm = realm
578 auth.AuthEnd = realm.End()
579 }
580 } else if p.matchTokenKind(TokenKindIdent) {
581 // Auth types like no_password, plaintext_password, etc.
582 authType := p.last().String
583 _ = p.lexer.consumeToken()
584 auth.AuthType = authType
585 auth.AuthEnd = p.last().End
586
587 if p.tryConsumeKeywords(KeywordBy) {
588 value, err := p.parseString(p.Pos())
589 if err != nil {
590 return nil, err
591 }
592 auth.AuthValue = value
593 auth.AuthEnd = value.End()
594 }
595 }
596 }

Callers 1

parseOptionalClausesMethod · 0.95

Calls 9

tryConsumeKeywordsMethod · 0.95
expectKeywordMethod · 0.95
lastMethod · 0.95
matchKeywordMethod · 0.95
parseStringMethod · 0.95
PosMethod · 0.95
matchTokenKindMethod · 0.95
consumeTokenMethod · 0.80
EndMethod · 0.65

Tested by

no test coverage detected