(pos Pos)
| 537 | } |
| 538 | |
| 539 | func (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 | } |
no test coverage detected