Skip to content

Authentication Implementation for Ruby #1757

Merged
osose-e merged 17 commits intoosose-authentication-featuresfrom
osose-authentication-atpinterface
Jul 21, 2022
Merged

Authentication Implementation for Ruby #1757
osose-e merged 17 commits intoosose-authentication-featuresfrom
osose-authentication-atpinterface

Conversation

@osose-e
Copy link
Contributor

@osose-e osose-e commented Jul 20, 2022

fixes #421
fixes #1638
fixes #1643

@osose-e osose-e closed this Jul 20, 2022
@osose-e osose-e reopened this Jul 20, 2022
@osose-e osose-e marked this pull request as draft July 20, 2022 21:42
@osose-e osose-e changed the title auth commit Authentication Implementation for Ruby Jul 20, 2022
@osose-e osose-e added the Ruby label Jul 21, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@osose-e osose-e marked this pull request as ready for review July 21, 2022 16:10
@osose-e osose-e merged commit de461ea into osose-authentication-features Jul 21, 2022
@osose-e osose-e deleted the osose-authentication-atpinterface branch July 21, 2022 16:10
@@ -0,0 +1,9 @@
example_id | status | run_time |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove this file and add a the extension to .gitignore

class AllowedHostsValidator
# creates a new AllocatedHostsValidator with provided values
def initialize(allowed_hosts)
@allowed_hosts = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was the implementation removed? this needs to be reverted

# allowed_hosts: an array of strings, where each string is an allowed host, default is empty
# scopes: an array of strings, where each string is a scope, default is empty array
# auth_code: a string containting the auth code; default is nil, can be updated post-initialization
def initialize(token_request_context, allowed_hosts = [], scopes = [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the first parameter needs to be removed and the implementation will call this base constructor

I also believe it should instantiate the host validator instead of throwing a not implemented exception

include Concurrent::Async

AUTHORIZATION_HEADER_KEY = 'Authorization'
def authenticate_request(request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was the implementation removed? it should provide a default implementation using the access token provider to avoid duplication

@@ -0,0 +1,43 @@
# frozen_string_literal: true

require 'oauth2'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be moved into its own library


module MicrosoftKiotaAuthentication
# Access Token Provider class implementation
class AccessTokenProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split into 2: the generic code needs to move to the access token provider in abstractions
the code that's specific to oauth2/microsoft identity platform stays here
and rename to azure access token provider


require 'uri'

module MicrosoftKiotaAuthentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to move back to abstractions

@@ -0,0 +1,10 @@
require 'concurrent'

module MicrosoftKiotaAuthentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it back to abstractions

@@ -0,0 +1,9 @@
module MicrosoftKiotaAuthentication
module AuthenticationProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move back to abstractions

require_relative './authentication_provider'
require_relative './access_token_provider'

module MicrosoftKiotaAuthentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move back to abstractions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants