Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
react-native-msal-module
Advanced tools
Looking for the MSAL plugin for React Native, here you are
Based on great plugin but deprecated react-native-msal-plugin
Support
$ npm install react-native-msal-module --save
Automatic linking is not tested. We recommend manual linking
Setting the plugin requires adding proper properties in Info.plist and AppDelegate.m . Here is the documentation of MSAL for iOS client. More in second point below.
...
# Lines below
pod 'MSAL', '~> 1.0.3' # <~ This line
pod 'react-native-msal-module', :path => '../node_modules/react-native-msal-module' # <~ this line
...
end
After that pod install
You need to implement Configuring MSAL step
AppDelegate.m
(3rd point of iOS only steps)- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [MSALPublicClientApplication handleMSALResponse:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
}
That's all!
First of all, according to the Android documentation and this plugin you should implement steps below:
Add file msal_config.json
(draft) in assets
directory in [your-project]/android/app/src/main
remember that redirect_uri
includes YOUR_BASE64_URL_ENCODED_PACKAGE_SIGNATURE
so you need BASE64 format of SIGNATURE parsed into URL. The same thing should be added in your Azure panel under redirect uris section
Also remember that your release signature differ with debug signature
Implement this step in your AndroidManifest.xml
Linking:
[your-project]/android/app/build.gradle
add:dependencies {
...
implementation project(':react-native-msal-module') // <~ add this line
...
}
[your-project]/android/settings.gradle
add:rootProject.name = '<NAME_OF_YOUR_PROJECT>'
...
include ':react-native-msal-module' // <~ add this line
project(':react-native-msal-module').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-msal-module/android') // <~ add this line
...
include ':app'
[your-project]/android/app/src/main/java/com/[your-project]/MainApplication.java
add:package <YOUR_APP_PACKAGE>
...
import com.reactlibrary.RNMsalModulePackage; // <~ add this line
...
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
...
new RNMsalModulePackage(), // <~ add this line
...
);
}
...
That's all, you did it!
import React from 'react';
import { View, Text } from 'react-native';
import MSAL from 'react-native-msal-module';
export class App extends React.Component {
componentDidMount() {
MSAL.init(<YOUR_CLIENT_ID>);
}
render() {
<View>
<Text>App</Text>
</View>
}
};
acquireTokenAsync: (scopes: string[]) => Promise<MSALResponse>;
import React from 'react';
import { View, Text } from 'react-native';
import MSAL from 'react-native-msal-module';
export class App extends React.Component {
async componentDidMount() {
// Acquire token can be executed only after successful initalization of MSAL
// Pass needed scopes
const msalResponse = await MSAL.acquireTokenAsync(scopes);
}
render() {
<View>
<Text>App</Text>
</View>
}
}
Parameter | type |
---|---|
accessToken | String |
idToken | String |
userId | String |
expiresOn | String |
userInfo | MSALUser type |
Parameter | type |
---|---|
username | String |
userIdentifier | String |
environment | String |
tenantId | String |
acquireTokenSilentAsync: (scopes: string[], userIdentifier: string) => Promise<MSALResponse>;
import React from 'react';
import { View, Text } from 'react-native';
import MSAL from 'react-native-msal-module';
export class App extends React.Component {
async componentDidMount() {
// Acquire token silent can be executed only after successful initalization of MSAL
// Pass userId retrieved from aqcuireToken and scopes
const msalResponse = await MSAL.acquireTokenSilentAsync(scopes, userId);
}
render() {
<View>
<Text>App</Text>
</View>
}
}
- idToken is currently unavailable in Android https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/850
It's unclear when official plugin will be released so for now:
FAQs
React Native module to cover iOS and Android client libraries
The npm package react-native-msal-module receives a total of 5 weekly downloads. As such, react-native-msal-module popularity was classified as not popular.
We found that react-native-msal-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.